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:
40 LatexDocVisitor(TextStream &t,OutputCodeList &ci,LatexCodeGenerator &lcg,
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) {}
125 const DocHtmlCell &cell;
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
176 TextStream &m_t;
177 OutputCodeList &m_ci;
178 LatexCodeGenerator &m_lcg;
181 bool m_hide;
182 QCString m_langExt;
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
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
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)