Imported Upstream version 1.8.15
[platform/upstream/doxygen.git] / src / latexgen.h
1 /******************************************************************************
2  *
3  * 
4  *
5  * Copyright (C) 1997-2015 by Dimitri van Heesch.
6  *
7  * Permission to use, copy, modify, and distribute this software and its
8  * documentation under the terms of the GNU General Public License is hereby 
9  * granted. No representations are made about the suitability of this software 
10  * for any purpose. It is provided "as is" without express or implied warranty.
11  * See the GNU General Public License for more details.
12  *
13  * Documents produced by Doxygen are derivative works derived from the
14  * input used in their production; they are not affected by this license.
15  *
16  */
17
18 #ifndef LATEXGEN_H
19 #define LATEXGEN_H
20
21 #include "outputgen.h"
22
23 class QFile;
24
25 static const char *latexStyleExtension = ".sty";
26
27 class LatexCodeGenerator : public CodeOutputInterface
28 {
29   public:
30     LatexCodeGenerator(FTextStream &t,const QCString &relPath,const QCString &sourceFile);
31     LatexCodeGenerator();
32     void setTextStream(FTextStream &t);
33     void setRelativePath(const QCString &path);
34     void setSourceFileName(const QCString &sourceFileName);
35     void codify(const char *text);
36     void writeCodeLink(const char *ref,const char *file,
37                        const char *anchor,const char *name,
38                        const char *tooltip);
39     void writeTooltip(const char *,
40                       const DocLinkInfo &,
41                       const char *,
42                       const char *,
43                       const SourceLinkInfo &,
44                       const SourceLinkInfo &
45                      ) {}
46     void writeLineNumber(const char *,const char *,const char *,int);
47     void startCodeLine(bool);
48     void endCodeLine();
49     void startFontClass(const char *);
50     void endFontClass();
51     void writeCodeAnchor(const char *) {}
52     void setCurrentDoc(Definition *,const char *,bool) {}
53     void addWord(const char *,bool) {}
54     static void setDoxyCodeOpen(bool val);
55
56   private:
57     void _writeCodeLink(const char *className,
58                         const char *ref,const char *file,
59                         const char *anchor,const char *name,
60                         const char *tooltip);
61     void docify(const char *str);
62     bool m_streamSet;
63     FTextStream m_t;
64     QCString m_relPath;
65     QCString m_sourceFileName;
66     int m_col;
67     bool m_prettyCode;
68 };
69
70 /** Generator for LaTeX output. */
71 class LatexGenerator : public OutputGenerator
72 {
73   public:
74     LatexGenerator();
75    ~LatexGenerator();
76     static void init();
77     static void writeStyleSheetFile(QFile &f);
78     static void writeHeaderFile(QFile &f);
79     static void writeFooterFile(QFile &f);
80
81     //OutputGenerator *copy();
82     //OutputGenerator *clone() { return new LatexGenerator(*this); }
83     //void append(const OutputGenerator *o);
84     void enable() 
85     { if (genStack->top()) active=*genStack->top(); else active=TRUE; }
86     void disable() { active=FALSE; }
87     void enableIf(OutputType o)  { if (o==Latex) enable();  }
88     void disableIf(OutputType o) { if (o==Latex) disable(); }
89     void disableIfNot(OutputType o) { if (o!=Latex) disable(); }
90     bool isEnabled(OutputType o) { return (o==Latex && active); } 
91     OutputGenerator *get(OutputType o) { return (o==Latex) ? this : 0; }
92
93     // --- CodeOutputInterface
94     void codify(const char *text)
95     { m_codeGen.codify(text); }
96     void writeCodeLink(const char *ref, const char *file,
97                        const char *anchor,const char *name,
98                        const char *tooltip)
99     { m_codeGen.writeCodeLink(ref,file,anchor,name,tooltip); }
100     void writeLineNumber(const char *ref,const char *file,const char *anchor,int lineNumber)
101     { m_codeGen.writeLineNumber(ref,file,anchor,lineNumber); }
102     void writeTooltip(const char *id, const DocLinkInfo &docInfo, const char *decl,
103                       const char *desc, const SourceLinkInfo &defInfo, const SourceLinkInfo &declInfo
104                      )
105     { m_codeGen.writeTooltip(id,docInfo,decl,desc,defInfo,declInfo); }
106     void startCodeLine(bool hasLineNumbers)
107     { m_codeGen.startCodeLine(hasLineNumbers); }
108     void endCodeLine()
109     { m_codeGen.endCodeLine(); }
110     void startFontClass(const char *s)
111     { m_codeGen.startFontClass(s); }
112     void endFontClass()
113     { m_codeGen.endFontClass(); }
114     void writeCodeAnchor(const char *anchor)
115     { m_codeGen.writeCodeAnchor(anchor); }
116     // ---------------------------
117
118
119     void writeDoc(DocNode *,Definition *ctx,MemberDef *);
120
121     void startFile(const char *name,const char *manName,const char *title);
122     void writeSearchInfo() {}
123     void writeFooter(const char *) {}
124     void endFile();
125     void clearBuffer();
126     
127     void startIndexSection(IndexSections);
128     void endIndexSection(IndexSections);
129     void writePageLink(const char *,bool);
130     void startProjectNumber();
131     void endProjectNumber() {}
132     void writeStyleInfo(int part);
133     void startTitleHead(const char *);
134     void startTitle();
135     void endTitleHead(const char *,const char *name);
136     void endTitle()   { t << "}"; }
137
138     void newParagraph();
139     void startParagraph(const char *classDef);
140     void endParagraph();
141     void writeString(const char *text);
142     void startIndexListItem() {}
143     void endIndexListItem() {}
144     void startIndexList() { t << "\\begin{DoxyCompactList}"    << endl; }
145     void endIndexList()   { t << "\\end{DoxyCompactList}"      << endl; }
146     void startIndexKey();
147     void endIndexKey();
148     void startIndexValue(bool);
149     void endIndexValue(const char *,bool);
150     void startItemList()  { t << "\\begin{DoxyCompactItemize}" << endl; }
151     void endItemList()    { t << "\\end{DoxyCompactItemize}"   << endl; }
152     void startIndexItem(const char *ref,const char *file);
153     void endIndexItem(const char *ref,const char *file);
154     void docify(const char *text);
155     void writeObjectLink(const char *ref,const char *file,
156                          const char *anchor,const char *name);
157
158     void startTextLink(const char *,const char *);
159     void endTextLink();
160     void startHtmlLink(const char *url);
161     void endHtmlLink();
162     void startTypewriter() { t << "{\\ttfamily "; }
163     void endTypewriter()   { t << "}";      }
164     void startGroupHeader(int);
165     void endGroupHeader(int);
166     void startItemListItem() { t << "\\item " << endl; }
167     void endItemListItem()   {}
168
169     void startMemberSections() {}
170     void endMemberSections() {} 
171     void startHeaderSection() {}
172     void endHeaderSection() {}
173     void startMemberHeader(const char *,int);
174     void endMemberHeader();
175     void startMemberSubtitle() {}
176     void endMemberSubtitle() {}
177     void startMemberDocList() {}
178     void endMemberDocList() {}
179     void startMemberList();
180     void endMemberList();
181     void startInlineHeader();
182     void endInlineHeader();
183     void startAnonTypeScope(int);
184     void endAnonTypeScope(int);
185     void startMemberItem(const char *,int,const char *);
186     void endMemberItem();
187     void startMemberTemplateParams();
188     void endMemberTemplateParams(const char *,const char *);
189
190     void startMemberGroupHeader(bool);
191     void endMemberGroupHeader();
192     void startMemberGroupDocs();
193     void endMemberGroupDocs();
194     void startMemberGroup();
195     void endMemberGroup(bool);
196     
197     void insertMemberAlign(bool) {}
198     void insertMemberAlignLeft(int,bool){}
199
200     void writeRuler() { t << endl << endl; }
201     void writeAnchor(const char *fileName,const char *name);
202     void startCodeFragment();
203     void endCodeFragment();
204     void startEmphasis() { t << "{\\em ";  }
205     void endEmphasis()   { t << "}"; }
206     void startBold()     { t << "{\\bfseries "; }
207     void endBold()       { t << "}"; }
208     void startDescription();
209     void endDescription();
210     void startDescItem();
211     void endDescItem();
212     void lineBreak(const char *style=0);
213     void startMemberDoc(const char *,const char *,const char *,const char *,int,int,bool);
214     void endMemberDoc(bool);
215     void startDoxyAnchor(const char *,const char *,const char *,const char *,const char *);
216     void endDoxyAnchor(const char *,const char *);
217     void writeChar(char c);
218     void writeLatexSpacing() { t << "\\hspace{0.3cm}"; }
219     void writeStartAnnoItem(const char *type,const char *file, 
220                             const char *path,const char *name);
221     void writeEndAnnoItem(const char *name);
222     void startSubsection() { t << "\\subsection*{"; }
223     void endSubsection() { t << "}" << endl; }
224     void startSubsubsection() { t << "\\subsubsection*{"; }
225     void endSubsubsection() { t << "}" << endl; }
226     void startCenter()      { t << "\\begin{center}" << endl; }
227     void endCenter()        { t << "\\end{center}" << endl; }
228     void startSmall()       { t << "\\footnotesize "; }
229     void endSmall()         { t << "\\normalsize "; }
230     void startMemberDescription(const char *,const char *,bool);
231     void endMemberDescription();
232     void startMemberDeclaration() {} 
233     void endMemberDeclaration(const char *,const char *) {}
234     void writeInheritedSectionTitle(const char *,const char *,const char *,
235                       const char *,const char *,const char *) {}
236     void startDescList(SectionTypes)     { t << "\\begin{Desc}\n\\item["; }
237     void endDescList()       { t << "\\end{Desc}" << endl; }
238     void startExamples();
239     void endExamples();
240     void startParamList(ParamListTypes,const char *title);
241     void endParamList();
242     void startDescForItem()     { t << "\\par" << endl; }
243     void endDescForItem()       {}
244     void startSection(const char *,const char *,SectionInfo::SectionType);
245     void endSection(const char *,SectionInfo::SectionType);
246     void addIndexItem(const char *,const char *);
247     void startIndent()       {}
248     void endIndent()         {}
249     void writeSynopsis()     {}
250     void startClassDiagram();
251     void endClassDiagram(const ClassDiagram &,const char *,const char *);
252     void startPageRef();
253     void endPageRef(const char *,const char *);
254     void startQuickIndices() {}
255     void endQuickIndices() {}
256     void writeSplitBar(const char *) {}
257     void writeNavigationPath(const char *) {}
258     void writeLogo() {}
259     void writeQuickLinks(bool,HighlightedItem,const char*) {}
260     void writeSummaryLink(const char *,const char *,const char *,bool) {}
261     void startContents() {}
262     void endContents() {}
263     void writeNonBreakableSpace(int);
264
265     void startDescTable(const char *title);
266     void endDescTable();
267     void startDescTableRow();
268     void endDescTableRow();
269     void startDescTableTitle();
270     void endDescTableTitle();
271     void startDescTableData();
272     void endDescTableData();
273     void lastIndexPage();
274
275     void startDotGraph();
276     void endDotGraph(const DotClassGraph &);
277     void startInclDepGraph();
278     void endInclDepGraph(const DotInclDepGraph &);
279     void startCallGraph();
280     void startGroupCollaboration();
281     void endGroupCollaboration(const DotGroupCollaboration &g);
282     void endCallGraph(const DotCallGraph &);
283     void startDirDepGraph();
284     void endDirDepGraph(const DotDirDeps &g);
285     void writeGraphicalHierarchy(const DotGfxHierarchyTable &) {}
286
287     void startTextBlock(bool) {}
288     void endTextBlock(bool) {}
289
290     void startMemberDocPrefixItem() {}
291     void endMemberDocPrefixItem() { t << "\\\\" << endl; }
292     void startMemberDocName(bool) {}
293     void endMemberDocName() {}
294     void startParameterType(bool,const char *);
295     void endParameterType();
296     void startParameterName(bool);
297     void endParameterName(bool,bool,bool);
298     void startParameterList(bool);
299     void endParameterList();
300     void exceptionEntry(const char*,bool);
301
302     void startConstraintList(const char *);
303     void startConstraintParam();
304     void endConstraintParam();
305     void startConstraintType();
306     void endConstraintType();
307     void startConstraintDocs();
308     void endConstraintDocs();
309     void endConstraintList();
310
311     void startMemberDocSimple(bool);
312     void endMemberDocSimple(bool);
313     void startInlineMemberType();
314     void endInlineMemberType();
315     void startInlineMemberName();
316     void endInlineMemberName();
317     void startInlineMemberDoc();
318     void endInlineMemberDoc();
319
320     void startLabels();
321     void writeLabel(const char *l,bool isLast);
322     void endLabels();
323
324     void setCurrentDoc(Definition *,const char *,bool) {}
325     void addWord(const char *,bool) {}
326
327
328   private:
329     LatexGenerator(const LatexGenerator &);
330     LatexGenerator &operator=(const LatexGenerator &);
331     bool insideTabbing;
332     bool firstDescItem;
333     bool disableLinks;
334     QCString relPath;
335     int m_indent;
336     bool templateMemberItem;
337     bool m_prettyCode;
338     LatexCodeGenerator m_codeGen;
339 };
340
341 #endif