1 /******************************************************************************
5 * Copyright (C) 1997-2015 by Dimitri van Heesch.
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.
13 * Documents produced by Doxygen are derivative works derived from the
14 * input used in their production; they are not affected by this license.
21 #include "outputgen.h"
25 static const char *latexStyleExtension = ".sty";
27 class LatexCodeGenerator : public CodeOutputInterface
30 LatexCodeGenerator(FTextStream &t,const QCString &relPath,const QCString &sourceFile);
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,
39 void writeTooltip(const char *,
43 const SourceLinkInfo &,
44 const SourceLinkInfo &
46 void writeLineNumber(const char *,const char *,const char *,int);
47 void startCodeLine(bool);
49 void startFontClass(const char *);
51 void writeCodeAnchor(const char *) {}
52 void setCurrentDoc(Definition *,const char *,bool) {}
53 void addWord(const char *,bool) {}
54 static void setDoxyCodeOpen(bool val);
57 void _writeCodeLink(const char *className,
58 const char *ref,const char *file,
59 const char *anchor,const char *name,
61 void docify(const char *str);
65 QCString m_sourceFileName;
70 /** Generator for LaTeX output. */
71 class LatexGenerator : public OutputGenerator
77 static void writeStyleSheetFile(QFile &f);
78 static void writeHeaderFile(QFile &f);
79 static void writeFooterFile(QFile &f);
81 //OutputGenerator *copy();
82 //OutputGenerator *clone() { return new LatexGenerator(*this); }
83 //void append(const OutputGenerator *o);
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; }
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,
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
105 { m_codeGen.writeTooltip(id,docInfo,decl,desc,defInfo,declInfo); }
106 void startCodeLine(bool hasLineNumbers)
107 { m_codeGen.startCodeLine(hasLineNumbers); }
109 { m_codeGen.endCodeLine(); }
110 void startFontClass(const char *s)
111 { m_codeGen.startFontClass(s); }
113 { m_codeGen.endFontClass(); }
114 void writeCodeAnchor(const char *anchor)
115 { m_codeGen.writeCodeAnchor(anchor); }
116 // ---------------------------
119 void writeDoc(DocNode *,Definition *ctx,MemberDef *);
121 void startFile(const char *name,const char *manName,const char *title);
122 void writeSearchInfo() {}
123 void writeFooter(const char *) {}
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 *);
135 void endTitleHead(const char *,const char *name);
136 void endTitle() { t << "}"; }
139 void startParagraph(const char *classDef);
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();
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);
158 void startTextLink(const char *,const char *);
160 void startHtmlLink(const char *url);
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() {}
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 *);
190 void startMemberGroupHeader(bool);
191 void endMemberGroupHeader();
192 void startMemberGroupDocs();
193 void endMemberGroupDocs();
194 void startMemberGroup();
195 void endMemberGroup(bool);
197 void insertMemberAlign(bool) {}
198 void insertMemberAlignLeft(int,bool){}
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();
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();
240 void startParamList(ParamListTypes,const char *title);
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() {}
249 void writeSynopsis() {}
250 void startClassDiagram();
251 void endClassDiagram(const ClassDiagram &,const char *,const char *);
253 void endPageRef(const char *,const char *);
254 void startQuickIndices() {}
255 void endQuickIndices() {}
256 void writeSplitBar(const char *) {}
257 void writeNavigationPath(const char *) {}
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);
265 void startDescTable(const char *title);
267 void startDescTableRow();
268 void endDescTableRow();
269 void startDescTableTitle();
270 void endDescTableTitle();
271 void startDescTableData();
272 void endDescTableData();
273 void lastIndexPage();
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 &) {}
287 void startTextBlock(bool) {}
288 void endTextBlock(bool) {}
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);
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();
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();
321 void writeLabel(const char *l,bool isLast);
324 void setCurrentDoc(Definition *,const char *,bool) {}
325 void addWord(const char *,bool) {}
329 LatexGenerator(const LatexGenerator &);
330 LatexGenerator &operator=(const LatexGenerator &);
336 bool templateMemberItem;
338 LatexCodeGenerator m_codeGen;