Doxygen
Loading...
Searching...
No Matches
latexdocvisitor.h
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Copyright (C) 1997-2021 by Dimitri van Heesch.
4 *
5 * Permission to use, copy, modify, and distribute this software and its
6 * documentation under the terms of the GNU General Public License is hereby
7 * granted. No representations are made about the suitability of this software
8 * for any purpose. It is provided "as is" without express or implied warranty.
9 * See the GNU General Public License for more details.
10 *
11 * Documents produced by Doxygen are derivative works derived from the
12 * input used in their production; they are not affected by this license.
13 *
14 */
15
16#ifndef LATEXDOCVISITOR_H
17#define LATEXDOCVISITOR_H
18
19#include <stack>
20
21#include "qcstring.h"
22#include "docvisitor.h"
23#include "docnode.h"
24
25class OutputCodeList;
27class TextStream;
28
29enum class TexOrPdf
30{
31 NO, //!< not called through texorpdf
32 TEX, //!< called through texorpdf as TeX (first) part
33 PDF, //!< called through texorpdf as PDF (second) part
34};
35
36/*! @brief Concrete visitor implementation for LaTeX output. */
38{
39 public:
41 const QCString &langExt, int hierarchyLevel = 0);
42
43 //--------------------------------------
44 // visitor functions for leaf nodes
45 //--------------------------------------
46
47 void operator()(const DocWord &);
48 void operator()(const DocLinkedWord &);
49 void operator()(const DocWhiteSpace &);
50 void operator()(const DocSymbol &);
51 void operator()(const DocEmoji &);
52 void operator()(const DocURL &);
53 void operator()(const DocLineBreak &);
54 void operator()(const DocHorRuler &);
55 void operator()(const DocStyleChange &);
56 void operator()(const DocVerbatim &);
57 void operator()(const DocAnchor &);
58 void operator()(const DocInclude &);
59 void operator()(const DocIncOperator &);
60 void operator()(const DocFormula &);
61 void operator()(const DocIndexEntry &);
62 void operator()(const DocSimpleSectSep &);
63 void operator()(const DocCite &);
64 void operator()(const DocSeparator &);
65
66 //--------------------------------------
67 // visitor functions for compound nodes
68 //--------------------------------------
69
70 void operator()(const DocAutoList &);
71 void operator()(const DocAutoListItem &);
72 void operator()(const DocPara &);
73 void operator()(const DocRoot &);
74 void operator()(const DocSimpleSect &);
75 void operator()(const DocTitle &);
76 void operator()(const DocSimpleList &);
77 void operator()(const DocSimpleListItem &);
78 void operator()(const DocSection &s);
79 void operator()(const DocHtmlList &s);
80 void operator()(const DocHtmlListItem &);
81 void operator()(const DocHtmlDescList &);
82 void operator()(const DocHtmlDescTitle &);
83 void operator()(const DocHtmlDescData &);
84 void operator()(const DocHtmlTable &t);
85 void operator()(const DocHtmlCaption &);
86 void operator()(const DocHtmlRow &);
87 void operator()(const DocHtmlCell &);
88 void operator()(const DocInternal &);
89 void operator()(const DocHRef &);
90 void operator()(const DocHtmlSummary &);
91 void operator()(const DocHtmlDetails &);
92 void operator()(const DocHtmlHeader &);
93 void operator()(const DocImage &);
94 void operator()(const DocDotFile &);
95 void operator()(const DocMscFile &);
96 void operator()(const DocDiaFile &);
97 void operator()(const DocPlantUmlFile &);
98 void operator()(const DocLink &lnk);
99 void operator()(const DocRef &ref);
100 void operator()(const DocSecRefItem &);
101 void operator()(const DocSecRefList &);
102 void operator()(const DocParamSect &);
103 void operator()(const DocParamList &);
104 void operator()(const DocXRefItem &);
105 void operator()(const DocInternalRef &);
106 void operator()(const DocText &);
107 void operator()(const DocHtmlBlockQuote &);
108 void operator()(const DocVhdlFlow &);
109 void operator()(const DocParBlock &);
110
111 private:
112 template<class T>
113 void visitChildren(const T &t)
114 {
115 for (const auto &child : t.children())
116 {
117 std::visit(*this, child);
118 }
119 }
120
122 {
123 ActiveRowSpan(const DocHtmlCell &c,size_t rs,size_t cs,size_t col)
124 : cell(c), rowSpan(rs), colSpan(cs), column(col) {}
126 size_t rowSpan;
127 size_t colSpan;
128 size_t column;
129 };
130
131 typedef std::vector<ActiveRowSpan> RowSpanList;
132
133 //--------------------------------------
134 // helper functions
135 //--------------------------------------
136
137 void filter(const QCString &str, const bool retainNewLine = false);
138 void startLink(const QCString &ref,const QCString &file,
139 const QCString &anchor,bool refToTable=false,bool refToSection=false);
140 void endLink(const QCString &ref,const QCString &file,
141 const QCString &anchor,bool refToTable=false,bool refToSection=false, SectionType sectionType = SectionType::Anchor);
142 QCString escapeMakeIndexChars(const char *s);
143 void startDotFile(const QCString &fileName,const QCString &width,
144 const QCString &height, bool hasCaption,
145 const QCString &srcFile,int srcLine);
146 void endDotFile(bool hasCaption);
147
148 void startMscFile(const QCString &fileName,const QCString &width,
149 const QCString &height, bool hasCaption,
150 const QCString &srcFile,int srcLine);
151 void endMscFile(bool hasCaption);
152 void writeMscFile(const QCString &fileName, const DocVerbatim &s);
153
154 void startDiaFile(const QCString &fileName,const QCString &width,
155 const QCString &height, bool hasCaption,
156 const QCString &srcFile,int srcLine);
157 void endDiaFile(bool hasCaption);
158 void writeDiaFile(const QCString &fileName, const DocVerbatim &s);
159 void writePlantUMLFile(const QCString &fileName, const DocVerbatim &s);
160 void startPlantUmlFile(const QCString &fileName,const QCString &width,
161 const QCString &height, bool hasCaption,
162 const QCString &srcFile,int srcLine);
163 void endPlantUmlFile(bool hasCaption);
164
165 void visitCaption(const DocNodeList &children);
166
167 void incIndentLevel();
168 void decIndentLevel();
169 int indentLevel() const;
170 const char *getSectionName(int level) const;
171
172 //--------------------------------------
173 // state variables
174 //--------------------------------------
175
181 bool m_hide;
185
187 {
189 size_t numCols = 0;
190 size_t currentColumn = 0;
191 bool inRowSpan = false;
192 bool inColSpan = false;
193 bool firstRow = false;
194 };
195 std::stack<TableState> m_tableStateStack; // needed for nested tables
197
198 static const int maxIndentLevels = 13;
200
202 {
203 bool isEnum = false;
204 };
205
207
209 {
210 m_tableStateStack.emplace();
211 }
213 {
214 m_tableStateStack.pop();
215 }
216 size_t currentColumn() const
217 {
218 return !m_tableStateStack.empty() ? m_tableStateStack.top().currentColumn : 0;
219 }
220 void setCurrentColumn(size_t col)
221 {
222 if (!m_tableStateStack.empty()) m_tableStateStack.top().currentColumn = col;
223 }
224 size_t numCols() const
225 {
226 return !m_tableStateStack.empty() ? m_tableStateStack.top().numCols : 0;
227 }
228 void setNumCols(size_t num)
229 {
230 if (!m_tableStateStack.empty()) m_tableStateStack.top().numCols = num;
231 }
232 bool inRowSpan() const
233 {
234 return !m_tableStateStack.empty() ? m_tableStateStack.top().inRowSpan : FALSE;
235 }
236 void setInRowSpan(bool b)
237 {
238 if (!m_tableStateStack.empty()) m_tableStateStack.top().inRowSpan = b;
239 }
240 bool inColSpan() const
241 {
242 return !m_tableStateStack.empty() ? m_tableStateStack.top().inColSpan : FALSE;
243 }
244 void setInColSpan(bool b)
245 {
246 if (!m_tableStateStack.empty()) m_tableStateStack.top().inColSpan = b;
247 }
248 bool firstRow() const
249 {
250 return !m_tableStateStack.empty() ? m_tableStateStack.top().firstRow : FALSE;
251 }
252 void setFirstRow(bool b)
253 {
254 if (!m_tableStateStack.empty()) m_tableStateStack.top().firstRow = b;
255 }
257 {
258 return !m_tableStateStack.empty() ? m_tableStateStack.top().rowSpans : m_emptyRowSpanList;
259 }
261 {
262 if (!m_tableStateStack.empty()) m_tableStateStack.top().rowSpans.push_back(std::move(span));
263 }
264 bool insideTable() const
265 {
266 return !m_tableStateStack.empty();
267 }
268
269};
270#endif
Node representing an anchor.
Definition docnode.h:228
Node representing an auto List.
Definition docnode.h:566
Node representing an item of a auto list.
Definition docnode.h:590
Node representing a citation of some bibliographic reference.
Definition docnode.h:244
Node representing a dia file.
Definition docnode.h:725
Node representing a dot file.
Definition docnode.h:707
Node representing an emoji.
Definition docnode.h:336
Node representing an item of a cross-referenced list.
Definition docnode.h:524
Node representing a Hypertext reference.
Definition docnode.h:817
Node representing a horizontal ruler.
Definition docnode.h:215
Node representing an HTML blockquote.
Definition docnode.h:1285
Node representing a HTML table caption.
Definition docnode.h:1222
Node representing a HTML table cell.
Definition docnode.h:1187
Node representing a HTML description data.
Definition docnode.h:1175
Node representing a Html description list.
Definition docnode.h:895
Node representing a Html description item.
Definition docnode.h:882
Node Html details.
Definition docnode.h:851
Node Html heading.
Definition docnode.h:867
Node representing a Html list.
Definition docnode.h:994
Node representing a HTML list item.
Definition docnode.h:1159
Node representing a HTML table row.
Definition docnode.h:1240
Node Html summary.
Definition docnode.h:838
Node representing a HTML table.
Definition docnode.h:1263
Node representing an image.
Definition docnode.h:636
Node representing a include/dontinclude operator block.
Definition docnode.h:472
Node representing an included text block from file.
Definition docnode.h:430
Node representing an entry in the index.
Definition docnode.h:547
Node representing an internal section of documentation.
Definition docnode.h:963
Node representing an internal reference to some item.
Definition docnode.h:801
Node representing a line break.
Definition docnode.h:201
Node representing a word that can be linked to something.
Definition docnode.h:164
Node representing a msc file.
Definition docnode.h:716
Node representing an block of paragraphs.
Definition docnode.h:973
Node representing a paragraph in the documentation tree.
Definition docnode.h:1074
Node representing a parameter list.
Definition docnode.h:1119
Node representing a parameter section.
Definition docnode.h:1047
Node representing a uml file.
Definition docnode.h:734
Node representing a reference to some item.
Definition docnode.h:772
Root node of documentation tree.
Definition docnode.h:1307
Node representing a reference to a section.
Definition docnode.h:929
Node representing a list of section references.
Definition docnode.h:953
Node representing a normal section.
Definition docnode.h:908
Node representing a separator.
Definition docnode.h:360
Node representing a simple list.
Definition docnode.h:984
Node representing a simple list item.
Definition docnode.h:1147
Node representing a simple section.
Definition docnode.h:1011
Node representing a separator between two simple sections of the same type.
Definition docnode.h:1038
Node representing a style change.
Definition docnode.h:264
Node representing a special symbol.
Definition docnode.h:323
Root node of a text fragment.
Definition docnode.h:1298
Node representing a simple section title.
Definition docnode.h:603
Node representing a URL (or email address)
Definition docnode.h:187
Node representing a verbatim, unparsed text fragment.
Definition docnode.h:371
Node representing a VHDL flow chart.
Definition docnode.h:743
Node representing some amount of white space.
Definition docnode.h:349
Node representing a word.
Definition docnode.h:152
Node representing an item of a cross-referenced list.
Definition docnode.h:615
Generator for LaTeX code fragments.
Definition latexgen.h:28
QCString escapeMakeIndexChars(const char *s)
void writeDiaFile(const QCString &fileName, const DocVerbatim &s)
void setFirstRow(bool b)
RowSpanList & rowSpans()
std::stack< TableState > m_tableStateStack
void setCurrentColumn(size_t col)
static const int maxIndentLevels
void endLink(const QCString &ref, const QCString &file, const QCString &anchor, bool refToTable=false, bool refToSection=false, SectionType sectionType=SectionType::Anchor)
bool firstRow() const
void endDotFile(bool hasCaption)
void operator()(const DocWord &)
void setInColSpan(bool b)
void visitCaption(const DocNodeList &children)
void addRowSpan(ActiveRowSpan &&span)
void setNumCols(size_t num)
void startLink(const QCString &ref, const QCString &file, const QCString &anchor, bool refToTable=false, bool refToSection=false)
OutputCodeList & m_ci
LatexDocVisitor(TextStream &t, OutputCodeList &ci, LatexCodeGenerator &lcg, const QCString &langExt, int hierarchyLevel=0)
size_t currentColumn() const
bool inRowSpan() const
void writePlantUMLFile(const QCString &fileName, const DocVerbatim &s)
void filter(const QCString &str, const bool retainNewLine=false)
void endMscFile(bool hasCaption)
void startDotFile(const QCString &fileName, const QCString &width, const QCString &height, bool hasCaption, const QCString &srcFile, int srcLine)
void startPlantUmlFile(const QCString &fileName, const QCString &width, const QCString &height, bool hasCaption, const QCString &srcFile, int srcLine)
LatexListItemInfo m_listItemInfo[maxIndentLevels]
bool insideTable() const
RowSpanList m_emptyRowSpanList
void endDiaFile(bool hasCaption)
std::vector< ActiveRowSpan > RowSpanList
bool inColSpan() const
const char * getSectionName(int level) const
void writeMscFile(const QCString &fileName, const DocVerbatim &s)
void endPlantUmlFile(bool hasCaption)
void startMscFile(const QCString &fileName, const QCString &width, const QCString &height, bool hasCaption, const QCString &srcFile, int srcLine)
void setInRowSpan(bool b)
void visitChildren(const T &t)
LatexCodeGenerator & m_lcg
void startDiaFile(const QCString &fileName, const QCString &width, const QCString &height, bool hasCaption, const QCString &srcFile, int srcLine)
size_t numCols() const
Class representing a list of different code generators.
Definition outputlist.h:164
This is an alternative implementation of QCString.
Definition qcstring.h:101
static constexpr int Anchor
Definition section.h:40
Text streaming class that buffers data.
Definition textstream.h:36
TexOrPdf
@ TEX
called through texorpdf as TeX (first) part
@ PDF
called through texorpdf as PDF (second) part
@ NO
not called through texorpdf
#define FALSE
Definition qcstring.h:34
ActiveRowSpan(const DocHtmlCell &c, size_t rs, size_t cs, size_t col)