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 DocMermaidFile &);
99 void operator()(const DocLink &lnk);
100 void operator()(const DocRef &ref);
101 void operator()(const DocSecRefItem &);
102 void operator()(const DocSecRefList &);
103 void operator()(const DocParamSect &);
104 void operator()(const DocParamList &);
105 void operator()(const DocXRefItem &);
106 void operator()(const DocInternalRef &);
107 void operator()(const DocText &);
108 void operator()(const DocHtmlBlockQuote &);
109 void operator()(const DocVhdlFlow &);
110 void operator()(const DocParBlock &);
111
112 private:
113 template<class T>
114 void visitChildren(const T &t)
115 {
116 for (const auto &child : t.children())
117 {
118 std::visit(*this, child);
119 }
120 }
121
123 {
124 ActiveRowSpan(const DocHtmlCell &c,size_t rs,size_t cs,size_t col)
125 : cell(c), rowSpan(rs), colSpan(cs), column(col) {}
127 size_t rowSpan;
128 size_t colSpan;
129 size_t column;
130 };
131
132 typedef std::vector<ActiveRowSpan> RowSpanList;
133
134 //--------------------------------------
135 // helper functions
136 //--------------------------------------
137
138 void filter(const QCString &str, const bool retainNewLine = false);
139 void startLink(const QCString &ref,const QCString &file,
140 const QCString &anchor,bool refToTable=false,bool refToSection=false);
141 void endLink(const QCString &ref,const QCString &file,
142 const QCString &anchor,bool refToTable=false,bool refToSection=false, SectionType sectionType = SectionType::Anchor);
143 void startDotFile(const QCString &fileName,const QCString &width,
144 const QCString &height, bool hasCaption,
145 const QCString &srcFile,int srcLine, bool newFile = true);
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,bool newFile = true);
151 void endMscFile(bool hasCaption);
152 void writeMscFile(const QCString &fileName, const DocVerbatim &s, bool newFile = true);
153
154 void startDiaFile(const QCString &fileName,const QCString &width,
155 const QCString &height, bool hasCaption,
156 const QCString &srcFile,int srcLine,bool newFile = true);
157 void endDiaFile(bool hasCaption);
158 void writePlantUMLFile(const QCString &fileName, const DocVerbatim &s);
159 void startPlantUmlFile(const QCString &fileName,const QCString &width,
160 const QCString &height, bool hasCaption,
161 const QCString &srcFile,int srcLine);
162 void endPlantUmlFile(bool hasCaption);
163 void writeMermaidFile(const QCString &baseName, const DocVerbatim &s);
164 void startMermaidFile(const QCString &fileName,const QCString &width,
165 const QCString &height, bool hasCaption,
166 const QCString &srcFile,int srcLine);
167 void endMermaidFile(bool hasCaption);
168
169 void visitCaption(const DocNodeList &children);
170
171 void incIndentLevel();
172 void decIndentLevel();
173 int indentLevel() const;
174 const char *getSectionName(int level) const;
175
176 //--------------------------------------
177 // state variables
178 //--------------------------------------
179
185 bool m_hide;
189
191 {
193 size_t numCols = 0;
194 size_t currentColumn = 0;
195 };
196 std::stack<TableState> m_tableStateStack; // needed for nested tables
198
199 static const int maxIndentLevels = 13;
201
203 {
204 bool isEnum = false;
205 };
206
208
210 {
211 m_tableStateStack.emplace();
212 }
214 {
215 m_tableStateStack.pop();
216 }
217 size_t currentColumn() const
218 {
219 return !m_tableStateStack.empty() ? m_tableStateStack.top().currentColumn : 0;
220 }
221 void setCurrentColumn(size_t col)
222 {
223 if (!m_tableStateStack.empty()) m_tableStateStack.top().currentColumn = col;
224 }
225 void setNumCols(size_t num)
226 {
227 if (!m_tableStateStack.empty()) m_tableStateStack.top().numCols = num;
228 }
230 {
231 return !m_tableStateStack.empty() ? m_tableStateStack.top().rowSpans : m_emptyRowSpanList;
232 }
234 {
235 if (!m_tableStateStack.empty()) m_tableStateStack.top().rowSpans.push_back(std::move(span));
236 }
237 bool insideTable() const
238 {
239 return !m_tableStateStack.empty();
240 }
241
242 bool isTableNested(const DocNodeVariant *n) const;
243 void writeStartTableCommand(const DocNodeVariant *n,size_t cols);
245
246};
247#endif
Node representing an anchor.
Definition docnode.h:229
Node representing an auto List.
Definition docnode.h:571
Node representing an item of a auto list.
Definition docnode.h:595
Node representing a citation of some bibliographic reference.
Definition docnode.h:245
Node representing a dia file.
Definition docnode.h:731
Node representing a dot file.
Definition docnode.h:713
Node representing an emoji.
Definition docnode.h:341
Node representing an item of a cross-referenced list.
Definition docnode.h:529
Node representing a Hypertext reference.
Definition docnode.h:832
Node representing a horizontal ruler.
Definition docnode.h:216
Node representing an HTML blockquote.
Definition docnode.h:1297
Node representing a HTML table caption.
Definition docnode.h:1234
Node representing a HTML table cell.
Definition docnode.h:1199
Node representing a HTML description data.
Definition docnode.h:1187
Node representing a Html description list.
Definition docnode.h:910
Node representing a Html description item.
Definition docnode.h:897
Node Html details.
Definition docnode.h:866
Node Html heading.
Definition docnode.h:882
Node representing a Html list.
Definition docnode.h:1009
Node representing a HTML list item.
Definition docnode.h:1171
Node representing a HTML table row.
Definition docnode.h:1252
Node Html summary.
Definition docnode.h:853
Node representing a HTML table.
Definition docnode.h:1275
Node representing an image.
Definition docnode.h:642
Node representing a include/dontinclude operator block.
Definition docnode.h:477
Node representing an included text block from file.
Definition docnode.h:435
Node representing an entry in the index.
Definition docnode.h:552
Node representing an internal section of documentation.
Definition docnode.h:978
Node representing an internal reference to some item.
Definition docnode.h:816
Node representing a line break.
Definition docnode.h:202
Node representing a word that can be linked to something.
Definition docnode.h:165
Node representing a mermaid file.
Definition docnode.h:749
Node representing a msc file.
Definition docnode.h:722
Node representing an block of paragraphs.
Definition docnode.h:988
Node representing a paragraph in the documentation tree.
Definition docnode.h:1089
Node representing a parameter list.
Definition docnode.h:1131
Node representing a parameter section.
Definition docnode.h:1062
Node representing a uml file.
Definition docnode.h:740
Node representing a reference to some item.
Definition docnode.h:787
Root node of documentation tree.
Definition docnode.h:1319
Node representing a reference to a section.
Definition docnode.h:944
Node representing a list of section references.
Definition docnode.h:968
Node representing a normal section.
Definition docnode.h:923
Node representing a separator.
Definition docnode.h:365
Node representing a simple list.
Definition docnode.h:999
Node representing a simple list item.
Definition docnode.h:1159
Node representing a simple section.
Definition docnode.h:1026
Node representing a separator between two simple sections of the same type.
Definition docnode.h:1053
Node representing a style change.
Definition docnode.h:268
Node representing a special symbol.
Definition docnode.h:328
Root node of a text fragment.
Definition docnode.h:1310
Node representing a simple section title.
Definition docnode.h:608
Node representing a URL (or email address).
Definition docnode.h:188
Node representing a verbatim, unparsed text fragment.
Definition docnode.h:376
Node representing a VHDL flow chart.
Definition docnode.h:758
Node representing some amount of white space.
Definition docnode.h:354
Node representing a word.
Definition docnode.h:153
Node representing an item of a cross-referenced list.
Definition docnode.h:621
Generator for LaTeX code fragments.
Definition latexgen.h:28
void startMermaidFile(const QCString &fileName, const QCString &width, const QCString &height, bool hasCaption, const QCString &srcFile, int srcLine)
void startDiaFile(const QCString &fileName, const QCString &width, const QCString &height, bool hasCaption, const QCString &srcFile, int srcLine, bool newFile=true)
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)
void startMscFile(const QCString &fileName, const QCString &width, const QCString &height, bool hasCaption, const QCString &srcFile, int srcLine, bool newFile=true)
void writeMermaidFile(const QCString &baseName, const DocVerbatim &s)
void endDotFile(bool hasCaption)
void operator()(const DocWord &)
void visitCaption(const DocNodeList &children)
void addRowSpan(ActiveRowSpan &&span)
void setNumCols(size_t num)
void writeStartTableCommand(const DocNodeVariant *n, size_t cols)
void writeEndTableCommand(const DocNodeVariant *n)
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
void writePlantUMLFile(const QCString &fileName, const DocVerbatim &s)
void filter(const QCString &str, const bool retainNewLine=false)
void endMscFile(bool hasCaption)
bool isTableNested(const DocNodeVariant *n) const
void startPlantUmlFile(const QCString &fileName, const QCString &width, const QCString &height, bool hasCaption, const QCString &srcFile, int srcLine)
void startDotFile(const QCString &fileName, const QCString &width, const QCString &height, bool hasCaption, const QCString &srcFile, int srcLine, bool newFile=true)
LatexListItemInfo m_listItemInfo[maxIndentLevels]
bool insideTable() const
RowSpanList m_emptyRowSpanList
void endDiaFile(bool hasCaption)
void endMermaidFile(bool hasCaption)
std::vector< ActiveRowSpan > RowSpanList
const char * getSectionName(int level) const
void endPlantUmlFile(bool hasCaption)
void writeMscFile(const QCString &fileName, const DocVerbatim &s, bool newFile=true)
void visitChildren(const T &t)
LatexCodeGenerator & m_lcg
Class representing a list of different code generators.
Definition outputlist.h:165
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
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:67
TexOrPdf
@ TEX
called through texorpdf as TeX (first) part
@ PDF
called through texorpdf as PDF (second) part
@ NO
not called through texorpdf
ActiveRowSpan(const DocHtmlCell &c, size_t rs, size_t cs, size_t col)