Doxygen
latexdocvisitor.h
浏览该文件的文档.
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 
24 class LatexCodeGenerator;
25 class TextStream;
26 
27 
28 /*! @brief Concrete visitor implementation for LaTeX output. */
30 {
31  public:
33  const QCString &langExt,bool insideTabbing);
34 
35  //--------------------------------------
36  // visitor functions for leaf nodes
37  //--------------------------------------
38 
39  void visit(DocWord *);
40  void visit(DocLinkedWord *);
41  void visit(DocWhiteSpace *);
42  void visit(DocSymbol *);
43  void visit(DocEmoji *);
44  void visit(DocURL *);
45  void visit(DocLineBreak *);
46  void visit(DocHorRuler *);
47  void visit(DocStyleChange *);
48  void visit(DocVerbatim *);
49  void visit(DocAnchor *);
50  void visit(DocInclude *);
51  void visit(DocIncOperator *);
52  void visit(DocFormula *);
53  void visit(DocIndexEntry *);
54  void visit(DocSimpleSectSep *);
55  void visit(DocCite *);
56 
57  //--------------------------------------
58  // visitor functions for compound nodes
59  //--------------------------------------
60 
61  void visitPre(DocAutoList *);
62  void visitPost(DocAutoList *);
63  void visitPre(DocAutoListItem *);
64  void visitPost(DocAutoListItem *);
65  void visitPre(DocPara *);
66  void visitPost(DocPara *);
67  void visitPre(DocRoot *);
68  void visitPost(DocRoot *);
69  void visitPre(DocSimpleSect *);
70  void visitPost(DocSimpleSect *);
71  void visitPre(DocTitle *);
72  void visitPost(DocTitle *);
73  void visitPre(DocSimpleList *);
74  void visitPost(DocSimpleList *);
77  void visitPre(DocSection *s);
78  void visitPost(DocSection *);
79  void visitPre(DocHtmlList *s);
80  void visitPost(DocHtmlList *s);
81  void visitPre(DocHtmlListItem *);
82  void visitPost(DocHtmlListItem *);
83  //void visitPre(DocHtmlPre *);
84  //void visitPost(DocHtmlPre *);
85  void visitPre(DocHtmlDescList *);
86  void visitPost(DocHtmlDescList *);
87  void visitPre(DocHtmlDescTitle *);
89  void visitPre(DocHtmlDescData *);
90  void visitPost(DocHtmlDescData *);
91  void visitPre(DocHtmlTable *t);
92  void visitPost(DocHtmlTable *t);
93  void visitPre(DocHtmlCaption *);
94  void visitPost(DocHtmlCaption *);
95  void visitPre(DocHtmlRow *);
96  void visitPost(DocHtmlRow *) ;
97  void visitPre(DocHtmlCell *);
98  void visitPost(DocHtmlCell *);
99  void visitPre(DocInternal *);
100  void visitPost(DocInternal *);
101  void visitPre(DocHRef *);
102  void visitPost(DocHRef *);
103  void visitPre(DocHtmlHeader *);
104  void visitPost(DocHtmlHeader *) ;
105  void visitPre(DocImage *);
106  void visitPost(DocImage *);
107  void visitPre(DocDotFile *);
108  void visitPost(DocDotFile *);
109  void visitPre(DocMscFile *);
110  void visitPost(DocMscFile *);
111  void visitPre(DocDiaFile *);
112  void visitPost(DocDiaFile *);
113  void visitPre(DocLink *lnk);
114  void visitPost(DocLink *);
115  void visitPre(DocRef *ref);
116  void visitPost(DocRef *);
117  void visitPre(DocSecRefItem *);
118  void visitPost(DocSecRefItem *);
119  void visitPre(DocSecRefList *);
120  void visitPost(DocSecRefList *);
121  void visitPre(DocParamSect *);
122  void visitPost(DocParamSect *);
123  void visitPre(DocParamList *);
124  void visitPost(DocParamList *);
125  void visitPre(DocXRefItem *);
126  void visitPost(DocXRefItem *);
127  void visitPre(DocInternalRef *);
128  void visitPost(DocInternalRef *);
129  void visitPre(DocText *);
130  void visitPost(DocText *);
131  void visitPre(DocHtmlBlockQuote *);
133  void visitPre(DocVhdlFlow *);
134  void visitPost(DocVhdlFlow *);
135  void visitPre(DocParBlock *);
136  void visitPost(DocParBlock *);
137 
138  private:
139 
141  {
142  ActiveRowSpan(DocHtmlCell *c,int rs,int cs,int col)
143  : cell(c), rowSpan(rs), colSpan(cs), column(col) {}
145  int rowSpan;
146  int colSpan;
147  int column;
148  };
149 
150  typedef std::vector<ActiveRowSpan> RowSpanList;
151 
152  //--------------------------------------
153  // helper functions
154  //--------------------------------------
155 
156  void filter(const QCString &str);
157  void startLink(const QCString &ref,const QCString &file,
158  const QCString &anchor,bool refToTable=FALSE);
159  void endLink(const QCString &ref,const QCString &file,
160  const QCString &anchor,bool refToTable=FALSE);
161  QCString escapeMakeIndexChars(const char *s);
162  void startDotFile(const QCString &fileName,const QCString &width,
163  const QCString &height, bool hasCaption,
164  const QCString &srcFile,int srcLine);
165  void endDotFile(bool hasCaption);
166 
167  void startMscFile(const QCString &fileName,const QCString &width,
168  const QCString &height, bool hasCaption,
169  const QCString &srcFile,int srcLine);
170  void endMscFile(bool hasCaption);
171  void writeMscFile(const QCString &fileName, DocVerbatim *s);
172 
173  void startDiaFile(const QCString &fileName,const QCString &width,
174  const QCString &height, bool hasCaption,
175  const QCString &srcFile,int srcLine);
176  void endDiaFile(bool hasCaption);
177  void writeDiaFile(const QCString &fileName, DocVerbatim *s);
178  void writePlantUMLFile(const QCString &fileName, DocVerbatim *s);
179 
180  void incIndentLevel();
181  void decIndentLevel();
182  int indentLevel() const;
183 
184  //--------------------------------------
185  // state variables
186  //--------------------------------------
187 
192  bool m_hide;
196 
197  struct TableState
198  {
200  int numCols = 0;
201  int currentColumn = 0;
202  bool inRowSpan = false;
203  bool inColSpan = false;
204  bool firstRow = false;
205  };
206  std::stack<TableState> m_tableStateStack; // needed for nested tables
208 
209  static const int maxIndentLevels = 13;
210  int m_indentLevel = 0;
211 
213  {
214  bool isEnum = false;
215  };
216 
218 
220  {
222  }
224  {
225  m_tableStateStack.pop();
226  }
227  int currentColumn() const
228  {
229  return !m_tableStateStack.empty() ? m_tableStateStack.top().currentColumn : 0;
230  }
231  void setCurrentColumn(int col)
232  {
233  if (!m_tableStateStack.empty()) m_tableStateStack.top().currentColumn = col;
234  }
235  int numCols() const
236  {
237  return !m_tableStateStack.empty() ? m_tableStateStack.top().numCols : 0;
238  }
239  void setNumCols(int num)
240  {
241  if (!m_tableStateStack.empty()) m_tableStateStack.top().numCols = num;
242  }
243  bool inRowSpan() const
244  {
245  return !m_tableStateStack.empty() ? m_tableStateStack.top().inRowSpan : FALSE;
246  }
247  void setInRowSpan(bool b)
248  {
249  if (!m_tableStateStack.empty()) m_tableStateStack.top().inRowSpan = b;
250  }
251  bool inColSpan() const
252  {
253  return !m_tableStateStack.empty() ? m_tableStateStack.top().inColSpan : FALSE;
254  }
255  void setInColSpan(bool b)
256  {
257  if (!m_tableStateStack.empty()) m_tableStateStack.top().inColSpan = b;
258  }
259  bool firstRow() const
260  {
261  return !m_tableStateStack.empty() ? m_tableStateStack.top().firstRow : FALSE;
262  }
263  void setFirstRow(bool b)
264  {
265  if (!m_tableStateStack.empty()) m_tableStateStack.top().firstRow = b;
266  }
268  {
269  return !m_tableStateStack.empty() ? m_tableStateStack.top().rowSpans : m_emptyRowSpanList;
270  }
272  {
273  if (!m_tableStateStack.empty()) m_tableStateStack.top().rowSpans.push_back(std::move(span));
274  }
275  bool insideTable() const
276  {
277  return !m_tableStateStack.empty();
278  }
279 
280 };
281 #endif
DocHtmlBlockQuote
Node representing an HTML blockquote
Definition: docparser.h:1433
DocAutoListItem
Node representing an item of a auto list
Definition: docparser.h:720
DocHRef
Node representing a Hypertext reference
Definition: docparser.h:936
DocStyleChange
Node representing a style change
Definition: docparser.h:343
DocVerbatim
Node representing a verbatim, unparsed text fragment
Definition: docparser.h:510
DocTitle
Node representing a simple section title
Definition: docparser.h:736
DocPara
Node representing a paragraph in the documentation tree
Definition: docparser.h:1178
LatexDocVisitor::firstRow
bool firstRow() const
Definition: latexdocvisitor.h:259
LatexDocVisitor::endMscFile
void endMscFile(bool hasCaption)
Definition: latexdocvisitor.cpp:2017
LatexDocVisitor::m_tableStateStack
std::stack< TableState > m_tableStateStack
Definition: latexdocvisitor.h:206
DocDotFile
Node representing a dot file
Definition: docparser.h:830
DocHtmlTable
Node representing a HTML table
Definition: docparser.h:1405
LatexDocVisitor::m_indentLevel
int m_indentLevel
Definition: latexdocvisitor.h:210
LatexDocVisitor::m_listItemInfo
LatexListItemInfo m_listItemInfo[maxIndentLevels]
Definition: latexdocvisitor.h:217
LatexDocVisitor::RowSpanList
std::vector< ActiveRowSpan > RowSpanList
Definition: latexdocvisitor.h:150
LatexDocVisitor::m_insideTabbing
bool m_insideTabbing
Definition: latexdocvisitor.h:194
DocRoot
Root node of documentation tree
Definition: docparser.h:1457
LatexDocVisitor::m_insidePre
bool m_insidePre
Definition: latexdocvisitor.h:190
DocHtmlHeader
Node Html heading
Definition: docparser.h:957
LatexDocVisitor::endDiaFile
void endDiaFile(bool hasCaption)
Definition: latexdocvisitor.cpp:2065
docvisitor.h
LatexDocVisitor::rowSpans
RowSpanList & rowSpans()
Definition: latexdocvisitor.h:267
DocHtmlListItem
Node representing a HTML list item
Definition: docparser.h:1286
LatexDocVisitor::m_insideItem
bool m_insideItem
Definition: latexdocvisitor.h:191
DocVhdlFlow
Node representing a VHDL flow chart
Definition: docparser.h:860
LatexDocVisitor::writePlantUMLFile
void writePlantUMLFile(const QCString &fileName, DocVerbatim *s)
Definition: latexdocvisitor.cpp:2087
DocHtmlDescData
Node representing a HTML description data
Definition: docparser.h:1303
LatexDocVisitor::visitPost
void visitPost(DocAutoList *)
Definition: latexdocvisitor.cpp:696
DocHtmlDescTitle
Node representing a Html description item
Definition: docparser.h:973
DocEmoji
Node representing a n emoji
Definition: docparser.h:469
DocMscFile
Node representing a msc file
Definition: docparser.h:840
LatexDocVisitor::escapeMakeIndexChars
QCString escapeMakeIndexChars(const char *s)
Definition: latexdocvisitor.cpp:151
DocSecRefItem
Node representing a reference to a section
Definition: docparser.h:1023
DocAnchor
Node representing an anchor
Definition: docparser.h:303
TextStream
Text streaming class that buffers data.
Definition: textstream.h:33
LatexDocVisitor::ActiveRowSpan
Definition: latexdocvisitor.h:140
DocText
Root node of a text fragment
Definition: docparser.h:1447
DocVisitor
Abstract visitor that participates in the visitor pattern.
Definition: docvisitor.h:92
LatexDocVisitor::pushTableState
void pushTableState()
Definition: latexdocvisitor.h:219
LatexDocVisitor::writeDiaFile
void writeDiaFile(const QCString &fileName, DocVerbatim *s)
Definition: latexdocvisitor.cpp:2072
qcstring.h
LatexDocVisitor::setInColSpan
void setInColSpan(bool b)
Definition: latexdocvisitor.h:255
LatexDocVisitor::endDotFile
void endDotFile(bool hasCaption)
Definition: latexdocvisitor.cpp:1986
LatexDocVisitor::LatexListItemInfo::isEnum
bool isEnum
Definition: latexdocvisitor.h:214
DocFormula
Node representing an item of a cross-referenced list
Definition: docparser.h:658
LatexDocVisitor::addRowSpan
void addRowSpan(ActiveRowSpan &&span)
Definition: latexdocvisitor.h:271
DocHtmlDescList
Node representing a Html description list
Definition: docparser.h:987
LatexDocVisitor::startDiaFile
void startDiaFile(const QCString &fileName, const QCString &width, const QCString &height, bool hasCaption, const QCString &srcFile, int srcLine)
Definition: latexdocvisitor.cpp:2040
DocIncOperator
Node representing a include/dontinclude operator block
Definition: docparser.h:606
DocIndexEntry
Node representing an entry in the index.
Definition: docparser.h:682
LatexDocVisitor::startDotFile
void startDotFile(const QCString &fileName, const QCString &width, const QCString &height, bool hasCaption, const QCString &srcFile, int srcLine)
Definition: latexdocvisitor.cpp:1961
DocSecRefList
Node representing a list of section references
Definition: docparser.h:1048
DocLineBreak
Node representing a line break
Definition: docparser.h:272
DocWord
Node representing a word
Definition: docparser.h:217
DocSymbol
Node representing a special symbol
Definition: docparser.h:385
LatexDocVisitor::m_langExt
QCString m_langExt
Definition: latexdocvisitor.h:195
LatexDocVisitor::LatexDocVisitor
LatexDocVisitor(TextStream &t, LatexCodeGenerator &ci, const QCString &langExt, bool insideTabbing)
Definition: latexdocvisitor.cpp:179
DocXRefItem
Node representing an item of a cross-referenced list
Definition: docparser.h:749
DocImage
Node representing an image
Definition: docparser.h:771
DocURL
Node representing a URL (or email address)
Definition: docparser.h:256
LatexDocVisitor::decIndentLevel
void decIndentLevel()
Definition: latexdocvisitor.cpp:2121
LatexDocVisitor::TableState::rowSpans
RowSpanList rowSpans
Definition: latexdocvisitor.h:199
DocHtmlCaption
Node representing a HTML table caption
Definition: docparser.h:1352
LatexDocVisitor::ActiveRowSpan::ActiveRowSpan
ActiveRowSpan(DocHtmlCell *c, int rs, int cs, int col)
Definition: latexdocvisitor.h:142
LatexDocVisitor::visit
void visit(DocWord *)
Definition: latexdocvisitor.cpp:191
DocParamList
Node representing a parameter list.
Definition: docparser.h:1228
LatexDocVisitor::setFirstRow
void setFirstRow(bool b)
Definition: latexdocvisitor.h:263
LatexDocVisitor::startMscFile
void startMscFile(const QCString &fileName, const QCString &width, const QCString &height, bool hasCaption, const QCString &srcFile, int srcLine)
Definition: latexdocvisitor.cpp:1992
LatexDocVisitor::m_ci
LatexCodeGenerator & m_ci
Definition: latexdocvisitor.h:189
DocParBlock
Node representing an block of paragraphs
Definition: docparser.h:1070
DocSimpleSectSep
Node representing a separator between two simple sections of the same type.
Definition: docparser.h:1139
LatexDocVisitor::endLink
void endLink(const QCString &ref, const QCString &file, const QCString &anchor, bool refToTable=FALSE)
Definition: latexdocvisitor.cpp:1940
LatexCodeGenerator
Definition: latexgen.h:28
LatexDocVisitor
Concrete visitor implementation for LaTeX output.
Definition: latexdocvisitor.h:29
LatexDocVisitor::incIndentLevel
void incIndentLevel()
Definition: latexdocvisitor.cpp:2112
DocCite
Node representing a citation of some bibliographic reference
Definition: docparser.h:321
LatexDocVisitor::currentColumn
int currentColumn() const
Definition: latexdocvisitor.h:227
DocRef
Node representing a reference to some item
Definition: docparser.h:891
LatexDocVisitor::m_t
TextStream & m_t
Definition: latexdocvisitor.h:188
DocParamSect
Node representing a parameter section
Definition: docparser.h:1150
DocHtmlList
Node representing a Html list
Definition: docparser.h:1093
LatexDocVisitor::maxIndentLevels
static const int maxIndentLevels
Definition: latexdocvisitor.h:209
LatexDocVisitor::TableState::inColSpan
bool inColSpan
Definition: latexdocvisitor.h:203
LatexDocVisitor::LatexListItemInfo
Definition: latexdocvisitor.h:212
LatexDocVisitor::setInRowSpan
void setInRowSpan(bool b)
Definition: latexdocvisitor.h:247
DocSimpleSect
Node representing a simple section
Definition: docparser.h:1111
DocSection
Node representing a normal section
Definition: docparser.h:1001
LatexDocVisitor::ActiveRowSpan::column
int column
Definition: latexdocvisitor.h:147
LatexDocVisitor::ActiveRowSpan::rowSpan
int rowSpan
Definition: latexdocvisitor.h:145
DocHorRuler
Node representing a horizontal ruler
Definition: docparser.h:288
LatexDocVisitor::setNumCols
void setNumCols(int num)
Definition: latexdocvisitor.h:239
DocInclude
Node representing an included text block from file
Definition: docparser.h:563
DocAutoList
Node representing an auto List
Definition: docparser.h:703
DocInternal
Node representing an internal section of documentation
Definition: docparser.h:1059
LatexDocVisitor::ActiveRowSpan::colSpan
int colSpan
Definition: latexdocvisitor.h:146
LatexDocVisitor::indentLevel
int indentLevel() const
Definition: latexdocvisitor.cpp:2107
DocLinkedWord
Node representing a word that can be linked to something
Definition: docparser.h:231
LatexDocVisitor::TableState::numCols
int numCols
Definition: latexdocvisitor.h:200
LatexDocVisitor::m_hideCaption
bool m_hideCaption
Definition: latexdocvisitor.h:193
LatexDocVisitor::filter
void filter(const QCString &str)
Definition: latexdocvisitor.cpp:1897
LatexDocVisitor::ActiveRowSpan::cell
DocHtmlCell * cell
Definition: latexdocvisitor.h:144
DocDiaFile
Node representing a dia file
Definition: docparser.h:850
LatexDocVisitor::inColSpan
bool inColSpan() const
Definition: latexdocvisitor.h:251
LatexDocVisitor::insideTable
bool insideTable() const
Definition: latexdocvisitor.h:275
LatexDocVisitor::numCols
int numCols() const
Definition: latexdocvisitor.h:235
LatexDocVisitor::TableState
Definition: latexdocvisitor.h:197
LatexDocVisitor::visitPre
void visitPre(DocAutoList *)
Definition: latexdocvisitor.cpp:680
DocSimpleList
Node representing a simple list
Definition: docparser.h:1082
DocSimpleListItem
Node representing a simple list item
Definition: docparser.h:1266
DocWhiteSpace
Node representing some amount of white space
Definition: docparser.h:484
DocHtmlCell
Node representing a HTML table cell
Definition: docparser.h:1316
LatexDocVisitor::inRowSpan
bool inRowSpan() const
Definition: latexdocvisitor.h:243
LatexDocVisitor::TableState::inRowSpan
bool inRowSpan
Definition: latexdocvisitor.h:202
LatexDocVisitor::TableState::currentColumn
int currentColumn
Definition: latexdocvisitor.h:201
DocInternalRef
Node representing an internal reference to some item
Definition: docparser.h:919
DocHtmlRow
Node representing a HTML table row
Definition: docparser.h:1371
LatexDocVisitor::setCurrentColumn
void setCurrentColumn(int col)
Definition: latexdocvisitor.h:231
LatexDocVisitor::m_hide
bool m_hide
Definition: latexdocvisitor.h:192
LatexDocVisitor::TableState::firstRow
bool firstRow
Definition: latexdocvisitor.h:204
LatexDocVisitor::startLink
void startLink(const QCString &ref, const QCString &file, const QCString &anchor, bool refToTable=FALSE)
Definition: latexdocvisitor.cpp:1908
LatexDocVisitor::writeMscFile
void writeMscFile(const QCString &fileName, DocVerbatim *s)
Definition: latexdocvisitor.cpp:2024
LatexDocVisitor::popTableState
void popTableState()
Definition: latexdocvisitor.h:223
FALSE
#define FALSE
Definition: qcstring.h:33
LatexDocVisitor::m_emptyRowSpanList
RowSpanList m_emptyRowSpanList
Definition: latexdocvisitor.h:207
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108