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) {}
56 void _writeCodeLink(const char *className,
57 const char *ref,const char *file,
58 const char *anchor,const char *name,
60 void docify(const char *str);
64 QCString m_sourceFileName;
69 /** Generator for LaTeX output. */
70 class LatexGenerator : public OutputGenerator
76 static void writeStyleSheetFile(QFile &f);
77 static void writeHeaderFile(QFile &f);
78 static void writeFooterFile(QFile &f);
80 //OutputGenerator *copy();
81 //OutputGenerator *clone() { return new LatexGenerator(*this); }
82 //void append(const OutputGenerator *o);
84 { if (genStack->top()) active=*genStack->top(); else active=TRUE; }
85 void disable() { active=FALSE; }
86 void enableIf(OutputType o) { if (o==Latex) enable(); }
87 void disableIf(OutputType o) { if (o==Latex) disable(); }
88 void disableIfNot(OutputType o) { if (o!=Latex) disable(); }
89 bool isEnabled(OutputType o) { return (o==Latex && active); }
90 OutputGenerator *get(OutputType o) { return (o==Latex) ? this : 0; }
92 // --- CodeOutputInterface
93 void codify(const char *text)
94 { m_codeGen.codify(text); }
95 void writeCodeLink(const char *ref, const char *file,
96 const char *anchor,const char *name,
98 { m_codeGen.writeCodeLink(ref,file,anchor,name,tooltip); }
99 void writeLineNumber(const char *ref,const char *file,const char *anchor,int lineNumber)
100 { m_codeGen.writeLineNumber(ref,file,anchor,lineNumber); }
101 void writeTooltip(const char *id, const DocLinkInfo &docInfo, const char *decl,
102 const char *desc, const SourceLinkInfo &defInfo, const SourceLinkInfo &declInfo
104 { m_codeGen.writeTooltip(id,docInfo,decl,desc,defInfo,declInfo); }
105 void startCodeLine(bool hasLineNumbers)
106 { m_codeGen.startCodeLine(hasLineNumbers); }
108 { m_codeGen.endCodeLine(); }
109 void startFontClass(const char *s)
110 { m_codeGen.startFontClass(s); }
112 { m_codeGen.endFontClass(); }
113 void writeCodeAnchor(const char *anchor)
114 { m_codeGen.writeCodeAnchor(anchor); }
115 // ---------------------------
118 void writeDoc(DocNode *,Definition *ctx,MemberDef *);
120 void startFile(const char *name,const char *manName,const char *title);
121 void writeSearchInfo() {}
122 void writeFooter(const char *) {}
126 void startIndexSection(IndexSections);
127 void endIndexSection(IndexSections);
128 void writePageLink(const char *,bool);
129 void startProjectNumber();
130 void endProjectNumber() {}
131 void writeStyleInfo(int part);
132 void startTitleHead(const char *);
134 void endTitleHead(const char *,const char *name);
135 void endTitle() { t << "}"; }
138 void startParagraph(const char *classDef);
140 void writeString(const char *text);
141 void startIndexListItem() {}
142 void endIndexListItem() {}
143 void startIndexList() { t << "\\begin{DoxyCompactList}" << endl; }
144 void endIndexList() { t << "\\end{DoxyCompactList}" << endl; }
145 void startIndexKey();
147 void startIndexValue(bool);
148 void endIndexValue(const char *,bool);
149 void startItemList() { t << "\\begin{DoxyCompactItemize}" << endl; }
150 void endItemList() { t << "\\end{DoxyCompactItemize}" << endl; }
151 void startIndexItem(const char *ref,const char *file);
152 void endIndexItem(const char *ref,const char *file);
153 void docify(const char *text);
154 void writeObjectLink(const char *ref,const char *file,
155 const char *anchor,const char *name);
157 void startTextLink(const char *,const char *);
159 void startHtmlLink(const char *url);
161 void startTypewriter() { t << "{\\ttfamily "; }
162 void endTypewriter() { t << "}"; }
163 void startGroupHeader(int);
164 void endGroupHeader(int);
165 void startItemListItem() { t << "\\item " << endl; }
166 void endItemListItem() {}
168 void startMemberSections() {}
169 void endMemberSections() {}
170 void startHeaderSection() {}
171 void endHeaderSection() {}
172 void startMemberHeader(const char *);
173 void endMemberHeader();
174 void startMemberSubtitle() {}
175 void endMemberSubtitle() {}
176 void startMemberDocList() {}
177 void endMemberDocList() {}
178 void startMemberList();
179 void endMemberList();
180 void startInlineHeader();
181 void endInlineHeader();
182 void startAnonTypeScope(int);
183 void endAnonTypeScope(int);
184 void startMemberItem(const char *,int,const char *);
185 void endMemberItem();
186 void startMemberTemplateParams();
187 void endMemberTemplateParams(const char *,const char *);
189 void startMemberGroupHeader(bool);
190 void endMemberGroupHeader();
191 void startMemberGroupDocs();
192 void endMemberGroupDocs();
193 void startMemberGroup();
194 void endMemberGroup(bool);
196 void insertMemberAlign(bool) {}
198 void writeRuler() { t << endl << endl; }
199 void writeAnchor(const char *fileName,const char *name);
200 void startCodeFragment();
201 void endCodeFragment();
202 void startEmphasis() { t << "{\\em "; }
203 void endEmphasis() { t << "}"; }
204 void startBold() { t << "{\\bfseries "; }
205 void endBold() { t << "}"; }
206 void startDescription();
207 void endDescription();
208 void startDescItem();
210 void lineBreak(const char *style=0);
211 void startMemberDoc(const char *,const char *,const char *,const char *,int,int,bool);
212 void endMemberDoc(bool);
213 void startDoxyAnchor(const char *,const char *,const char *,const char *,const char *);
214 void endDoxyAnchor(const char *,const char *);
215 void writeChar(char c);
216 void writeLatexSpacing() { t << "\\hspace{0.3cm}"; }
217 void writeStartAnnoItem(const char *type,const char *file,
218 const char *path,const char *name);
219 void writeEndAnnoItem(const char *name);
220 void startSubsection() { t << "\\subsection*{"; }
221 void endSubsection() { t << "}" << endl; }
222 void startSubsubsection() { t << "\\subsubsection*{"; }
223 void endSubsubsection() { t << "}" << endl; }
224 void startCenter() { t << "\\begin{center}" << endl; }
225 void endCenter() { t << "\\end{center}" << endl; }
226 void startSmall() { t << "\\footnotesize "; }
227 void endSmall() { t << "\\normalsize "; }
228 void startMemberDescription(const char *,const char *);
229 void endMemberDescription();
230 void startMemberDeclaration() {}
231 void endMemberDeclaration(const char *,const char *) {}
232 void writeInheritedSectionTitle(const char *,const char *,const char *,
233 const char *,const char *,const char *) {}
234 void startDescList(SectionTypes) { t << "\\begin{Desc}\n\\item["; }
235 void endDescList() { t << "\\end{Desc}" << endl; }
236 void startSimpleSect(SectionTypes,const char *,const char *,const char *);
237 void endSimpleSect();
238 void startParamList(ParamListTypes,const char *title);
240 void startDescForItem() { t << "\\par" << endl; }
241 void endDescForItem() {}
242 void startSection(const char *,const char *,SectionInfo::SectionType);
243 void endSection(const char *,SectionInfo::SectionType);
244 void addIndexItem(const char *,const char *);
245 void startIndent() {}
247 void writeSynopsis() {}
248 void startClassDiagram();
249 void endClassDiagram(const ClassDiagram &,const char *,const char *);
251 void endPageRef(const char *,const char *);
252 void startQuickIndices() {}
253 void endQuickIndices() {}
254 void writeSplitBar(const char *) {}
255 void writeNavigationPath(const char *) {}
257 void writeQuickLinks(bool,HighlightedItem,const char*) {}
258 void writeSummaryLink(const char *,const char *,const char *,bool) {}
259 void startContents() {}
260 void endContents() {}
261 void writeNonBreakableSpace(int);
263 void startDescTable(const char *title);
265 void startDescTableRow();
266 void endDescTableRow();
267 void startDescTableTitle();
268 void endDescTableTitle();
269 void startDescTableData();
270 void endDescTableData();
271 void lastIndexPage();
273 void startDotGraph();
274 void endDotGraph(const DotClassGraph &);
275 void startInclDepGraph();
276 void endInclDepGraph(const DotInclDepGraph &);
277 void startCallGraph();
278 void startGroupCollaboration();
279 void endGroupCollaboration(const DotGroupCollaboration &g);
280 void endCallGraph(const DotCallGraph &);
281 void startDirDepGraph();
282 void endDirDepGraph(const DotDirDeps &g);
283 void writeGraphicalHierarchy(const DotGfxHierarchyTable &) {}
285 void startTextBlock(bool) {}
286 void endTextBlock(bool) {}
288 void startMemberDocPrefixItem() {}
289 void endMemberDocPrefixItem() { t << "\\\\" << endl; }
290 void startMemberDocName(bool) {}
291 void endMemberDocName() {}
292 void startParameterType(bool,const char *);
293 void endParameterType();
294 void startParameterName(bool);
295 void endParameterName(bool,bool,bool);
296 void startParameterList(bool);
297 void endParameterList();
298 void exceptionEntry(const char*,bool);
300 void startConstraintList(const char *);
301 void startConstraintParam();
302 void endConstraintParam();
303 void startConstraintType();
304 void endConstraintType();
305 void startConstraintDocs();
306 void endConstraintDocs();
307 void endConstraintList();
309 void startMemberDocSimple(bool);
310 void endMemberDocSimple(bool);
311 void startInlineMemberType();
312 void endInlineMemberType();
313 void startInlineMemberName();
314 void endInlineMemberName();
315 void startInlineMemberDoc();
316 void endInlineMemberDoc();
319 void writeLabel(const char *l,bool isLast);
322 void setCurrentDoc(Definition *,const char *,bool) {}
323 void addWord(const char *,bool) {}
327 LatexGenerator(const LatexGenerator &);
328 LatexGenerator &operator=(const LatexGenerator &);
334 bool templateMemberItem;
336 LatexCodeGenerator m_codeGen;