Fix for UBSan build
[platform/upstream/doxygen.git] / src / latexdocvisitor.h
1 /******************************************************************************
2  *
3  * $Id: $
4  *
5  *
6  * Copyright (C) 1997-2012 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;
29 class CodeOutputInterface;
30
31 /*! @brief Concrete visitor implementation for LaTeX output. */
32 class LatexDocVisitor : public DocVisitor
33 {
34   public:
35     LatexDocVisitor(FTextStream &t,CodeOutputInterface &ci,
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 *);
77     void visitPre(DocSimpleListItem *);
78     void visitPost(DocSimpleListItem *);
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 *);
90     void visitPost(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(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(DocCopy *);
130     void visitPost(DocCopy *);
131     void visitPre(DocText *);
132     void visitPost(DocText *);
133     void visitPre(DocHtmlBlockQuote *);
134     void visitPost(DocHtmlBlockQuote *);
135
136   private:
137
138     struct ActiveRowSpan
139     {
140       ActiveRowSpan(DocHtmlCell *c,int rs,int cs,int col) 
141         : cell(c), rowSpan(rs), colSpan(cs), column(col) {}
142       DocHtmlCell *cell;
143       int rowSpan;
144       int colSpan;
145       int column;
146     };
147
148     typedef QList<ActiveRowSpan> RowSpanList;
149
150     //--------------------------------------
151     // helper functions 
152     //--------------------------------------
153     
154     void filter(const char *str);
155     void startLink(const QCString &ref,const QCString &file,
156                    const QCString &anchor);
157     void endLink(const QCString &ref,const QCString &file,
158                  const QCString &anchor);
159     QCString escapeMakeIndexChars(const char *s);
160     void startDotFile(const QCString &fileName,const QCString &width,
161                       const QCString &height, bool hasCaption);
162     void endDotFile(bool hasCaption);
163
164     void startMscFile(const QCString &fileName,const QCString &width,
165                       const QCString &height, bool hasCaption);
166     void endMscFile(bool hasCaption);
167     void writeMscFile(const QCString &fileName);
168
169     void pushEnabled();
170     void popEnabled();
171
172     //--------------------------------------
173     // state variables
174     //--------------------------------------
175
176     FTextStream &m_t;
177     CodeOutputInterface &m_ci;
178     bool m_insidePre;
179     bool m_insideItem;
180     bool m_hide;
181     bool m_insideTabbing;
182     bool m_insideTable;
183     int  m_numCols;
184     QStack<bool> m_enabled;
185     QCString m_langExt;
186     RowSpanList m_rowSpans;
187     int m_currentColumn;
188     bool m_inRowspan;
189     bool m_inColspan;
190 };
191
192 #endif