latexdocvisitor.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  *
4  *
5  *
6  * Copyright (C) 1997-2015 by Dimitri van Heesch.
7  *
8  * Permission to use, copy, modify, and distribute this software and its
9  * documentation under the terms of the GNU General Public License is hereby
10  * granted. No representations are made about the suitability of this software
11  * for any purpose. It is provided "as is" without express or implied warranty.
12  * See the GNU General Public License for more details.
13  *
14  * Documents produced by Doxygen are derivative works derived from the
15  * input used in their production; they are not affected by this license.
16  *
17  */
18 
19 #ifndef _LATEXDOCVISITOR_H
20 #define _LATEXDOCVISITOR_H
21 
22 #include "docvisitor.h"
23 #include <qstack.h>
24 #include <qcstring.h>
25 #include <qlist.h>
26 //#include <qmap.h>
27 
28 class FTextStream;
30 
31 /*! @brief Concrete visitor implementation for LaTeX output. */
33 {
34  public:
36  const char *langExt,bool insideTabbing);
37 
38  //--------------------------------------
39  // visitor functions for leaf nodes
40  //--------------------------------------
41 
42  void visit(DocWord *);
43  void visit(DocLinkedWord *);
44  void visit(DocWhiteSpace *);
45  void visit(DocSymbol *);
46  void visit(DocURL *);
47  void visit(DocLineBreak *);
48  void visit(DocHorRuler *);
49  void visit(DocStyleChange *);
50  void visit(DocVerbatim *);
51  void visit(DocAnchor *);
52  void visit(DocInclude *);
53  void visit(DocIncOperator *);
54  void visit(DocFormula *);
55  void visit(DocIndexEntry *);
56  void visit(DocSimpleSectSep *);
57  void visit(DocCite *);
58 
59  //--------------------------------------
60  // visitor functions for compound nodes
61  //--------------------------------------
62 
63  void visitPre(DocAutoList *);
64  void visitPost(DocAutoList *);
65  void visitPre(DocAutoListItem *);
66  void visitPost(DocAutoListItem *);
67  void visitPre(DocPara *);
68  void visitPost(DocPara *);
69  void visitPre(DocRoot *);
70  void visitPost(DocRoot *);
71  void visitPre(DocSimpleSect *);
72  void visitPost(DocSimpleSect *);
73  void visitPre(DocTitle *);
74  void visitPost(DocTitle *);
75  void visitPre(DocSimpleList *);
76  void visitPost(DocSimpleList *);
79  void visitPre(DocSection *s);
80  void visitPost(DocSection *);
81  void visitPre(DocHtmlList *s);
82  void visitPost(DocHtmlList *s);
83  void visitPre(DocHtmlListItem *);
84  void visitPost(DocHtmlListItem *);
85  //void visitPre(DocHtmlPre *);
86  //void visitPost(DocHtmlPre *);
87  void visitPre(DocHtmlDescList *);
88  void visitPost(DocHtmlDescList *);
89  void visitPre(DocHtmlDescTitle *);
91  void visitPre(DocHtmlDescData *);
92  void visitPost(DocHtmlDescData *);
93  void visitPre(DocHtmlTable *t);
94  void visitPost(DocHtmlTable *t);
95  void visitPre(DocHtmlCaption *);
96  void visitPost(DocHtmlCaption *);
97  void visitPre(DocHtmlRow *);
98  void visitPost(DocHtmlRow *) ;
99  void visitPre(DocHtmlCell *);
100  void visitPost(DocHtmlCell *);
101  void visitPre(DocInternal *);
102  void visitPost(DocInternal *);
103  void visitPre(DocHRef *);
104  void visitPost(DocHRef *);
105  void visitPre(DocHtmlHeader *);
106  void visitPost(DocHtmlHeader *) ;
107  void visitPre(DocImage *);
108  void visitPost(DocImage *);
109  void visitPre(DocDotFile *);
110  void visitPost(DocDotFile *);
111  void visitPre(DocMscFile *);
112  void visitPost(DocMscFile *);
113  void visitPre(DocDiaFile *);
114  void visitPost(DocDiaFile *);
115  void visitPre(DocLink *lnk);
116  void visitPost(DocLink *);
117  void visitPre(DocRef *ref);
118  void visitPost(DocRef *);
119  void visitPre(DocSecRefItem *);
120  void visitPost(DocSecRefItem *);
121  void visitPre(DocSecRefList *);
122  void visitPost(DocSecRefList *);
123  void visitPre(DocParamSect *);
124  void visitPost(DocParamSect *);
125  void visitPre(DocParamList *);
126  void visitPost(DocParamList *);
127  void visitPre(DocXRefItem *);
128  void visitPost(DocXRefItem *);
129  void visitPre(DocInternalRef *);
130  void visitPost(DocInternalRef *);
131  void visitPre(DocCopy *);
132  void visitPost(DocCopy *);
133  void visitPre(DocText *);
134  void visitPost(DocText *);
135  void visitPre(DocHtmlBlockQuote *);
137  void visitPre(DocVhdlFlow *);
138  void visitPost(DocVhdlFlow *);
139  void visitPre(DocParBlock *);
140  void visitPost(DocParBlock *);
141 
142  private:
143 
145  {
146  ActiveRowSpan(DocHtmlCell *c,int rs,int cs,int col)
147  : cell(c), rowSpan(rs), colSpan(cs), column(col) {}
149  int rowSpan;
150  int colSpan;
151  int column;
152  };
153 
155 
156  //--------------------------------------
157  // helper functions
158  //--------------------------------------
159 
160  void filter(const char *str);
161  void startLink(const QCString &ref,const QCString &file,
162  const QCString &anchor,bool refToTable=FALSE);
163  void endLink(const QCString &ref,const QCString &file,
164  const QCString &anchor);
165  QCString escapeMakeIndexChars(const char *s);
166  void startDotFile(const QCString &fileName,const QCString &width,
167  const QCString &height, bool hasCaption);
168  void endDotFile(bool hasCaption);
169 
170  void startMscFile(const QCString &fileName,const QCString &width,
171  const QCString &height, bool hasCaption);
172  void endMscFile(bool hasCaption);
173  void writeMscFile(const QCString &fileName, DocVerbatim *s);
174 
175  void startDiaFile(const QCString &fileName,const QCString &width,
176  const QCString &height, bool hasCaption);
177  void endDiaFile(bool hasCaption);
178  void writeDiaFile(const QCString &fileName, DocVerbatim *s);
180 
181  void pushEnabled();
182  void popEnabled();
183 
184  //--------------------------------------
185  // state variables
186  //--------------------------------------
187 
192  bool m_hide;
197 
198  struct TableState
199  {
203  RowSpanList rowSpans;
204  int numCols;
206  bool inRowSpan;
207  bool inColSpan;
208  bool firstRow;
209  };
210  QStack<TableState> m_tableStateStack; // needed for nested tables
211  RowSpanList m_emptyRowSpanList;
212 
214  {
215  m_tableStateStack.push(new TableState);
216  }
218  {
219  delete m_tableStateStack.pop();
220  }
221  int currentColumn() const
222  {
223  return !m_tableStateStack.isEmpty() ? m_tableStateStack.top()->currentColumn : 0;
224  }
225  void setCurrentColumn(int col)
226  {
227  if (!m_tableStateStack.isEmpty()) m_tableStateStack.top()->currentColumn = col;
228  }
229  int numCols() const
230  {
231  return !m_tableStateStack.isEmpty() ? m_tableStateStack.top()->numCols : 0;
232  }
233  void setNumCols(int num)
234  {
235  if (!m_tableStateStack.isEmpty()) m_tableStateStack.top()->numCols = num;
236  }
237  bool inRowSpan() const
238  {
239  return !m_tableStateStack.isEmpty() ? m_tableStateStack.top()->inRowSpan : FALSE;
240  }
241  void setInRowSpan(bool b)
242  {
243  if (!m_tableStateStack.isEmpty()) m_tableStateStack.top()->inRowSpan = b;
244  }
245  bool inColSpan() const
246  {
247  return !m_tableStateStack.isEmpty() ? m_tableStateStack.top()->inColSpan : FALSE;
248  }
249  void setInColSpan(bool b)
250  {
251  if (!m_tableStateStack.isEmpty()) m_tableStateStack.top()->inColSpan = b;
252  }
253  bool firstRow() const
254  {
255  return !m_tableStateStack.isEmpty() ? m_tableStateStack.top()->firstRow : FALSE;
256  }
257  void setFirstRow(bool b)
258  {
259  if (!m_tableStateStack.isEmpty()) m_tableStateStack.top()->firstRow = b;
260  }
261  const RowSpanList &rowSpans()
262  {
263  return !m_tableStateStack.isEmpty() ? m_tableStateStack.top()->rowSpans : m_emptyRowSpanList;
264  }
266  {
267  if (!m_tableStateStack.isEmpty()) m_tableStateStack.top()->rowSpans.append(span);
268  }
269  bool insideTable() const
270  {
271  return !m_tableStateStack.isEmpty();
272  }
273 
274 };
275 
276 #endif
void writePlantUMLFile(const QCString &fileName, DocVerbatim *s)
span(IterB &&b, IterE &&e, Adaptor &&adaptor) -> span< decltype(adaptor(std::forward< IterB >(b))), decltype(adaptor(std::forward< IterE >(e))) >
void setInColSpan(bool b)
void endMscFile(bool hasCaption)
void startMscFile(const QCString &fileName, const QCString &width, const QCString &height, bool hasCaption)
void startLink(const QCString &ref, const QCString &file, const QCString &anchor, bool refToTable=FALSE)
LatexDocVisitor(FTextStream &t, CodeOutputInterface &ci, const char *langExt, bool insideTabbing)
void visit(DocWord *)
const bool FALSE
Definition: qglobal.h:370
Simplified and optimized version of QTextStream.
Definition: ftextstream.h:11
void startDotFile(const QCString &fileName, const QCString &width, const QCString &height, bool hasCaption)
bool insideTable() const
Concrete visitor implementation for LaTeX output.
void push(const type *d)
Definition: qstack.h:58
Abstract visitor that participates in the visitor pattern.
Definition: docvisitor.h:90
void visitPre(DocAutoList *)
CodeOutputInterface & m_ci
void setNumCols(int num)
bool firstRow() const
void visitPost(DocAutoList *)
fileName
Definition: dumpTree.py:9
int currentColumn() const
bool isEmpty() const
Definition: qstack.h:57
void writeDiaFile(const QCString &fileName, DocVerbatim *s)
void setInRowSpan(bool b)
void endDotFile(bool hasCaption)
void endDiaFile(bool hasCaption)
void endLink(const QCString &ref, const QCString &file, const QCString &anchor)
QCString escapeMakeIndexChars(const char *s)
type * pop()
Definition: qstack.h:59
const RowSpanList & rowSpans()
FTextStream & m_t
void filter(const char *str)
std::vector< std::string > column
void setCurrentColumn(int col)
int numCols() const
void setFirstRow(bool b)
static bool * b
Definition: config.cpp:1043
QList< ActiveRowSpan > RowSpanList
void writeMscFile(const QCString &fileName, DocVerbatim *s)
QStack< bool > m_enabled
const char * cs
RowSpanList m_emptyRowSpanList
void setAutoDelete(bool enable)
Definition: qlist.h:99
ActiveRowSpan(DocHtmlCell *c, int rs, int cs, int col)
bool inRowSpan() const
void startDiaFile(const QCString &fileName, const QCString &width, const QCString &height, bool hasCaption)
static QCString * s
Definition: config.cpp:1042
const bool TRUE
Definition: qglobal.h:371
static QCString str
type * top() const
Definition: qstack.h:63
void addRowSpan(ActiveRowSpan *span)
QStack< TableState > m_tableStateStack
bool inColSpan() const