Root/
Source at commit 1322 created 12 years 7 months ago. By meklort, Add doxygen to utils folder | |
---|---|
1 | /******************************************************************************␊ |
2 | *␊ |
3 | * $Id: $␊ |
4 | *␊ |
5 | *␊ |
6 | * Copyright (C) 1997-2011 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 | #include <qfileinfo.h> ␊ |
19 | #include "latexdocvisitor.h"␊ |
20 | #include "docparser.h"␊ |
21 | #include "language.h"␊ |
22 | #include "doxygen.h"␊ |
23 | #include "outputgen.h"␊ |
24 | #include "dot.h"␊ |
25 | #include "util.h"␊ |
26 | #include "message.h"␊ |
27 | #include "parserintf.h"␊ |
28 | #include "msc.h"␊ |
29 | #include "htmlattrib.h"␊ |
30 | ␊ |
31 | static QCString escapeLabelName(const char *s)␊ |
32 | {␊ |
33 | QCString result;␊ |
34 | const char *p=s;␊ |
35 | char c;␊ |
36 | while ((c=*p++))␊ |
37 | {␊ |
38 | switch (c)␊ |
39 | {␊ |
40 | case '%': result+="\\%"; break;␊ |
41 | case '|': result+="\\texttt{\"|}"; break;␊ |
42 | case '!': result+="\"!"; break;␊ |
43 | default: result+=c;␊ |
44 | }␊ |
45 | }␊ |
46 | return result;␊ |
47 | }␊ |
48 | ␊ |
49 | const int maxLevels=5;␊ |
50 | static const char *secLabels[maxLevels] = ␊ |
51 | { "section","subsection","subsubsection","paragraph","subparagraph" };␊ |
52 | ␊ |
53 | static const char *getSectionName(int level)␊ |
54 | {␊ |
55 | int l = level;␊ |
56 | if (Config_getBool("COMPACT_LATEX")) l++;␊ |
57 | if (Doxygen::insideMainPage) l--;␊ |
58 | return secLabels[QMIN(maxLevels-1,l)];␊ |
59 | }␊ |
60 | ␊ |
61 | static int rowspan(DocHtmlCell *cell)␊ |
62 | {␊ |
63 | int retval = 0;␊ |
64 | HtmlAttribList attrs = cell->attribs ();␊ |
65 | for (unsigned int i = 0; i < attrs.count(); ++i) ␊ |
66 | {␊ |
67 | if ("rowspan" == attrs.at(i)->name.lower())␊ |
68 | {␊ |
69 | retval = attrs.at(i)->value.toInt();␊ |
70 | break;␊ |
71 | }␊ |
72 | }␊ |
73 | return retval;␊ |
74 | }␊ |
75 | ␊ |
76 | QCString LatexDocVisitor::escapeMakeIndexChars(const char *s)␊ |
77 | {␊ |
78 | QCString result;␊ |
79 | const char *p=s;␊ |
80 | char str[2]; str[1]=0;␊ |
81 | char c;␊ |
82 | while ((c=*p++))␊ |
83 | {␊ |
84 | switch (c)␊ |
85 | {␊ |
86 | case '!': m_t << "\"!"; break;␊ |
87 | case '"': m_t << "\"\""; break;␊ |
88 | case '@': m_t << "\"@"; break;␊ |
89 | case '|': m_t << "\\texttt{\"|}"; break;␊ |
90 | case '[': m_t << "["; break;␊ |
91 | case ']': m_t << "]"; break;␊ |
92 | default: str[0]=c; filter(str); break;␊ |
93 | }␊ |
94 | }␊ |
95 | return result;␊ |
96 | }␊ |
97 | ␊ |
98 | ␊ |
99 | LatexDocVisitor::LatexDocVisitor(FTextStream &t,CodeOutputInterface &ci,␊ |
100 | const char *langExt,bool insideTabbing) ␊ |
101 | : DocVisitor(DocVisitor_Latex), m_t(t), m_ci(ci), m_insidePre(FALSE), ␊ |
102 | m_insideItem(FALSE), m_hide(FALSE), m_insideTabbing(insideTabbing),␊ |
103 | m_langExt(langExt), m_currentColumn(0), m_inRowspan(FALSE)␊ |
104 | {␊ |
105 | }␊ |
106 | ␊ |
107 | //--------------------------------------␊ |
108 | // visitor functions for leaf nodes␊ |
109 | //--------------------------------------␊ |
110 | ␊ |
111 | void LatexDocVisitor::visit(DocWord *w)␊ |
112 | {␊ |
113 | if (m_hide) return;␊ |
114 | filter(w->word());␊ |
115 | }␊ |
116 | ␊ |
117 | void LatexDocVisitor::visit(DocLinkedWord *w)␊ |
118 | {␊ |
119 | if (m_hide) return;␊ |
120 | startLink(w->ref(),w->file(),w->anchor());␊ |
121 | filter(w->word());␊ |
122 | endLink(w->ref(),w->file(),w->anchor());␊ |
123 | }␊ |
124 | ␊ |
125 | void LatexDocVisitor::visit(DocWhiteSpace *w)␊ |
126 | {␊ |
127 | if (m_hide) return;␊ |
128 | if (m_insidePre)␊ |
129 | {␊ |
130 | m_t << w->chars();␊ |
131 | }␊ |
132 | else␊ |
133 | {␊ |
134 | m_t << " ";␊ |
135 | }␊ |
136 | }␊ |
137 | ␊ |
138 | void LatexDocVisitor::visit(DocSymbol *s)␊ |
139 | {␊ |
140 | if (m_hide) return;␊ |
141 | switch(s->symbol())␊ |
142 | {␊ |
143 | case DocSymbol::BSlash: m_t << "$\\backslash$"; break;␊ |
144 | case DocSymbol::At: m_t << "@"; break;␊ |
145 | case DocSymbol::Less: if (m_insidePre) m_t << "<"; else m_t << "$<$"; ␊ |
146 | break;␊ |
147 | case DocSymbol::Greater: if (m_insidePre) m_t << ">"; else m_t << "$>$"; break;␊ |
148 | case DocSymbol::Amp: m_t << "\\&"; break;␊ |
149 | case DocSymbol::Dollar: m_t << "\\$"; break;␊ |
150 | case DocSymbol::Hash: m_t << "\\#"; break;␊ |
151 | case DocSymbol::DoubleColon: m_t << "::"; break;␊ |
152 | case DocSymbol::Percent: m_t << "\\%"; break;␊ |
153 | case DocSymbol::Copy: m_t << "\\copyright"; break;␊ |
154 | case DocSymbol::Tm: m_t << "\\texttrademark"; break;␊ |
155 | case DocSymbol::Reg: m_t << "\\textregistered"; break;␊ |
156 | case DocSymbol::Apos: m_t << "'"; break;␊ |
157 | case DocSymbol::Quot: m_t << "\""; break;␊ |
158 | case DocSymbol::Lsquo: m_t << "`"; break;␊ |
159 | case DocSymbol::Rsquo: m_t << "'"; break;␊ |
160 | case DocSymbol::Ldquo: m_t << "``"; break;␊ |
161 | case DocSymbol::Rdquo: m_t << "''"; break;␊ |
162 | case DocSymbol::Ndash: m_t << "--"; break;␊ |
163 | case DocSymbol::Mdash: m_t << "---"; break;␊ |
164 | case DocSymbol::Uml: ␊ |
165 | if (s->letter()=='i') ␊ |
166 | m_t << "\\\"{\\i}"; ␊ |
167 | else ␊ |
168 | m_t << "\\\"{" << s->letter() << "}"; ␊ |
169 | break;␊ |
170 | case DocSymbol::Acute: ␊ |
171 | if (s->letter()=='i') ␊ |
172 | m_t << "\\'{\\i}"; ␊ |
173 | else ␊ |
174 | m_t << "\\'{" << s->letter() << "}"; ␊ |
175 | break;␊ |
176 | case DocSymbol::Grave: ␊ |
177 | if (s->letter()=='i') ␊ |
178 | m_t << "\\`{\\i}"; ␊ |
179 | else ␊ |
180 | m_t << "\\`{" << s->letter() << "}"; ␊ |
181 | break;␊ |
182 | case DocSymbol::Circ: ␊ |
183 | if (s->letter()=='i') ␊ |
184 | m_t << "\\^{\\i}"; ␊ |
185 | else ␊ |
186 | m_t << "\\^{" << s->letter() << "}"; ␊ |
187 | break;␊ |
188 | case DocSymbol::Slash: if (tolower(s->letter())=='o')␊ |
189 | m_t << "{\\" << s->letter() << "}";␊ |
190 | else␊ |
191 | m_t << s->letter();␊ |
192 | break;␊ |
193 | case DocSymbol::Tilde: m_t << "\\~{" << s->letter() << "}"; break;␊ |
194 | case DocSymbol::Szlig: m_t << "{\\ss}"; break;␊ |
195 | case DocSymbol::Cedil: m_t << "\\c{" << s->letter() << "}"; break;␊ |
196 | case DocSymbol::Ring: m_t << "\\" << s->letter() << s->letter(); break;␊ |
197 | case DocSymbol::Nbsp: m_t << "~"; break;␊ |
198 | case DocSymbol::AElig: m_t << "{\\AE}"; break;␊ |
199 | case DocSymbol::Aelig: m_t << "{\\ae}"; break;␊ |
200 | default:␊ |
201 | err("error: unknown symbol found\n");␊ |
202 | }␊ |
203 | }␊ |
204 | ␊ |
205 | void LatexDocVisitor::visit(DocURL *u)␊ |
206 | {␊ |
207 | if (m_hide) return;␊ |
208 | if (Config_getBool("PDF_HYPERLINKS"))␊ |
209 | {␊ |
210 | m_t << "\\href{";␊ |
211 | if (u->isEmail()) m_t << "mailto:";␊ |
212 | m_t << u->url() << "}";␊ |
213 | }␊ |
214 | m_t << "{\\tt ";␊ |
215 | filter(u->url());␊ |
216 | m_t << "}";␊ |
217 | }␊ |
218 | ␊ |
219 | void LatexDocVisitor::visit(DocLineBreak *)␊ |
220 | {␊ |
221 | if (m_hide) return;␊ |
222 | m_t << "\\par\n";␊ |
223 | }␊ |
224 | ␊ |
225 | void LatexDocVisitor::visit(DocHorRuler *)␊ |
226 | {␊ |
227 | if (m_hide) return;␊ |
228 | m_t << "\n\n";␊ |
229 | }␊ |
230 | ␊ |
231 | void LatexDocVisitor::visit(DocStyleChange *s)␊ |
232 | {␊ |
233 | if (m_hide) return;␊ |
234 | switch (s->style())␊ |
235 | {␊ |
236 | case DocStyleChange::Bold:␊ |
237 | if (s->enable()) m_t << "{\\bfseries "; else m_t << "}";␊ |
238 | break;␊ |
239 | case DocStyleChange::Italic:␊ |
240 | if (s->enable()) m_t << "{\\itshape "; else m_t << "\\/}";␊ |
241 | break;␊ |
242 | case DocStyleChange::Code:␊ |
243 | if (s->enable()) m_t << "{\\ttfamily "; else m_t << "}";␊ |
244 | break;␊ |
245 | case DocStyleChange::Subscript:␊ |
246 | if (s->enable()) m_t << "$_{\\mbox{"; else m_t << "}}$ ";␊ |
247 | break;␊ |
248 | case DocStyleChange::Superscript:␊ |
249 | if (s->enable()) m_t << "$^{\\mbox{"; else m_t << "}}$ ";␊ |
250 | break;␊ |
251 | case DocStyleChange::Center:␊ |
252 | if (s->enable()) m_t << "\\begin{center}"; else m_t << "\\end{center} ";␊ |
253 | break;␊ |
254 | case DocStyleChange::Small:␊ |
255 | if (s->enable()) m_t << "\n\\footnotesize "; else m_t << "\n\\normalsize ";␊ |
256 | break;␊ |
257 | case DocStyleChange::Preformatted:␊ |
258 | if (s->enable()) ␊ |
259 | {␊ |
260 | m_t << "\n\\begin{DoxyPre}";␊ |
261 | m_insidePre=TRUE;␊ |
262 | }␊ |
263 | else␊ |
264 | {␊ |
265 | m_insidePre=FALSE;␊ |
266 | m_t << "\\end{DoxyPre}\n";␊ |
267 | }␊ |
268 | break;␊ |
269 | case DocStyleChange::Div: /* HTML only */ break;␊ |
270 | case DocStyleChange::Span: /* HTML only */ break;␊ |
271 | }␊ |
272 | }␊ |
273 | ␊ |
274 | void LatexDocVisitor::visit(DocVerbatim *s)␊ |
275 | {␊ |
276 | //static bool latexSourceCode = Config_getBool("LATEX_SOURCE_CODE");␊ |
277 | if (m_hide) return;␊ |
278 | switch(s->type())␊ |
279 | {␊ |
280 | case DocVerbatim::Code: ␊ |
281 | //if (latexSourceCode)␊ |
282 | //{␊ |
283 | // m_t << "\n\n\\begin{footnotesize}\\begin{alltt}" << endl; ␊ |
284 | //}␊ |
285 | //else␊ |
286 | {␊ |
287 | m_t << "\n\\begin{DoxyCode}\n";␊ |
288 | }␊ |
289 | Doxygen::parserManager->getParser(m_langExt)␊ |
290 | ->parseCode(m_ci,s->context(),s->text(),␊ |
291 | s->isExample(),s->exampleFile());␊ |
292 | //if (latexSourceCode)␊ |
293 | //{␊ |
294 | // m_t << "\\end{alltt}\\end{footnotesize}" << endl; ␊ |
295 | //}␊ |
296 | //else␊ |
297 | {␊ |
298 | m_t << "\\end{DoxyCode}\n";␊ |
299 | }␊ |
300 | break;␊ |
301 | case DocVerbatim::Verbatim: ␊ |
302 | m_t << "\\begin{DoxyVerb}";␊ |
303 | m_t << s->text();␊ |
304 | m_t << "\\end{DoxyVerb}\n";␊ |
305 | break;␊ |
306 | case DocVerbatim::HtmlOnly: ␊ |
307 | case DocVerbatim::XmlOnly: ␊ |
308 | case DocVerbatim::ManOnly: ␊ |
309 | /* nothing */ ␊ |
310 | break;␊ |
311 | case DocVerbatim::LatexOnly: ␊ |
312 | m_t << s->text(); ␊ |
313 | break;␊ |
314 | case DocVerbatim::Dot: ␊ |
315 | {␊ |
316 | static int dotindex = 1;␊ |
317 | QCString fileName(4096);␊ |
318 | ␊ |
319 | fileName.sprintf("%s%d%s", ␊ |
320 | (Config_getString("LATEX_OUTPUT")+"/inline_dotgraph_").data(), ␊ |
321 | dotindex++,␊ |
322 | ".dot"␊ |
323 | );␊ |
324 | QFile file(fileName);␊ |
325 | if (!file.open(IO_WriteOnly))␊ |
326 | {␊ |
327 | err("Could not open file %s for writing\n",fileName.data());␊ |
328 | }␊ |
329 | file.writeBlock( s->text(), s->text().length() );␊ |
330 | file.close();␊ |
331 | ␊ |
332 | m_t << "\\begin{center}\n";␊ |
333 | startDotFile(fileName,"","",FALSE);␊ |
334 | endDotFile(FALSE);␊ |
335 | m_t << "\\end{center}\n";␊ |
336 | ␊ |
337 | if (Config_getBool("DOT_CLEANUP")) file.remove();␊ |
338 | }␊ |
339 | break;␊ |
340 | case DocVerbatim::Msc: ␊ |
341 | {␊ |
342 | static int mscindex = 1;␊ |
343 | QCString baseName(4096);␊ |
344 | ␊ |
345 | baseName.sprintf("%s%d", ␊ |
346 | (Config_getString("LATEX_OUTPUT")+"/inline_mscgraph_").data(), ␊ |
347 | mscindex++␊ |
348 | );␊ |
349 | QFile file(baseName+".msc");␊ |
350 | if (!file.open(IO_WriteOnly))␊ |
351 | {␊ |
352 | err("Could not open file %s.msc for writing\n",baseName.data());␊ |
353 | }␊ |
354 | QCString text = "msc {";␊ |
355 | text+=s->text();␊ |
356 | text+="}";␊ |
357 | file.writeBlock( text, text.length() );␊ |
358 | file.close();␊ |
359 | ␊ |
360 | m_t << "\\begin{center}\n";␊ |
361 | writeMscFile(baseName);␊ |
362 | m_t << "\\end{center}\n";␊ |
363 | ␊ |
364 | if (Config_getBool("DOT_CLEANUP")) file.remove();␊ |
365 | }␊ |
366 | break;␊ |
367 | }␊ |
368 | }␊ |
369 | ␊ |
370 | void LatexDocVisitor::visit(DocAnchor *anc)␊ |
371 | {␊ |
372 | if (m_hide) return;␊ |
373 | m_t << "\\label{" << anc->file() << "_" << anc->anchor() << "}" << endl;␊ |
374 | if (!anc->file().isEmpty() && Config_getBool("PDF_HYPERLINKS")) ␊ |
375 | {␊ |
376 | m_t << "\\hypertarget{" << anc->file() << "_" << anc->anchor() ␊ |
377 | << "}{}" << endl;␊ |
378 | } ␊ |
379 | }␊ |
380 | ␊ |
381 | void LatexDocVisitor::visit(DocInclude *inc)␊ |
382 | {␊ |
383 | if (m_hide) return;␊ |
384 | switch(inc->type())␊ |
385 | {␊ |
386 | case DocInclude::IncWithLines:␊ |
387 | { ␊ |
388 | m_t << "\n\\begin{DoxyCodeInclude}\n";␊ |
389 | QFileInfo cfi( inc->file() );␊ |
390 | FileDef fd( cfi.dirPath(), cfi.fileName() );␊ |
391 | Doxygen::parserManager->getParser(inc->extension())␊ |
392 | ->parseCode(m_ci,inc->context(),␊ |
393 | inc->text(),␊ |
394 | inc->isExample(),␊ |
395 | inc->exampleFile(), &fd);␊ |
396 | m_t << "\\end{DoxyCodeInclude}" << endl;␊ |
397 | }␊ |
398 | break; ␊ |
399 | case DocInclude::Include: ␊ |
400 | m_t << "\n\\begin{DoxyCodeInclude}\n";␊ |
401 | Doxygen::parserManager->getParser(inc->extension())␊ |
402 | ->parseCode(m_ci,inc->context(),␊ |
403 | inc->text(),inc->isExample(),␊ |
404 | inc->exampleFile());␊ |
405 | m_t << "\\end{DoxyCodeInclude}\n";␊ |
406 | break;␊ |
407 | case DocInclude::DontInclude: ␊ |
408 | break;␊ |
409 | case DocInclude::HtmlInclude: ␊ |
410 | break;␊ |
411 | case DocInclude::VerbInclude: ␊ |
412 | m_t << "\n\\begin{DoxyVerbInclude}\n";␊ |
413 | m_t << inc->text();␊ |
414 | m_t << "\\end{DoxyVerbInclude}\n";␊ |
415 | break;␊ |
416 | }␊ |
417 | }␊ |
418 | ␊ |
419 | void LatexDocVisitor::visit(DocIncOperator *op)␊ |
420 | {␊ |
421 | //printf("DocIncOperator: type=%d first=%d, last=%d text=`%s'\n",␊ |
422 | // op->type(),op->isFirst(),op->isLast(),op->text().data());␊ |
423 | if (op->isFirst()) ␊ |
424 | {␊ |
425 | if (!m_hide) m_t << "\n\\begin{DoxyCodeInclude}\n";␊ |
426 | pushEnabled();␊ |
427 | m_hide = TRUE;␊ |
428 | }␊ |
429 | if (op->type()!=DocIncOperator::Skip) ␊ |
430 | {␊ |
431 | popEnabled();␊ |
432 | if (!m_hide) ␊ |
433 | {␊ |
434 | Doxygen::parserManager->getParser(m_langExt)␊ |
435 | ->parseCode(m_ci,op->context(),op->text(),␊ |
436 | op->isExample(),op->exampleFile());␊ |
437 | }␊ |
438 | pushEnabled();␊ |
439 | m_hide=TRUE;␊ |
440 | }␊ |
441 | if (op->isLast()) ␊ |
442 | {␊ |
443 | popEnabled();␊ |
444 | if (!m_hide) m_t << "\n\\end{DoxyCodeInclude}\n";␊ |
445 | }␊ |
446 | else␊ |
447 | {␊ |
448 | if (!m_hide) m_t << endl;␊ |
449 | }␊ |
450 | }␊ |
451 | ␊ |
452 | void LatexDocVisitor::visit(DocFormula *f)␊ |
453 | {␊ |
454 | if (m_hide) return;␊ |
455 | m_t << f->text();␊ |
456 | }␊ |
457 | ␊ |
458 | void LatexDocVisitor::visit(DocIndexEntry *i)␊ |
459 | {␊ |
460 | if (m_hide) return;␊ |
461 | m_t << "\\index{" << escapeLabelName(i->entry()) << "@{";␊ |
462 | escapeMakeIndexChars(i->entry());␊ |
463 | m_t << "}}";␊ |
464 | }␊ |
465 | ␊ |
466 | void LatexDocVisitor::visit(DocSimpleSectSep *)␊ |
467 | {␊ |
468 | }␊ |
469 | ␊ |
470 | //--------------------------------------␊ |
471 | // visitor functions for compound nodes␊ |
472 | //--------------------------------------␊ |
473 | ␊ |
474 | void LatexDocVisitor::visitPre(DocAutoList *l)␊ |
475 | {␊ |
476 | if (m_hide) return;␊ |
477 | if (l->isEnumList())␊ |
478 | {␊ |
479 | m_t << "\n\\begin{DoxyEnumerate}";␊ |
480 | }␊ |
481 | else␊ |
482 | {␊ |
483 | m_t << "\n\\begin{DoxyItemize}";␊ |
484 | }␊ |
485 | }␊ |
486 | ␊ |
487 | void LatexDocVisitor::visitPost(DocAutoList *l)␊ |
488 | {␊ |
489 | if (m_hide) return;␊ |
490 | if (l->isEnumList())␊ |
491 | {␊ |
492 | m_t << "\n\\end{DoxyEnumerate}";␊ |
493 | }␊ |
494 | else␊ |
495 | {␊ |
496 | m_t << "\n\\end{DoxyItemize}";␊ |
497 | }␊ |
498 | }␊ |
499 | ␊ |
500 | void LatexDocVisitor::visitPre(DocAutoListItem *)␊ |
501 | {␊ |
502 | if (m_hide) return;␊ |
503 | m_t << "\n\\item ";␊ |
504 | }␊ |
505 | ␊ |
506 | void LatexDocVisitor::visitPost(DocAutoListItem *) ␊ |
507 | {␊ |
508 | }␊ |
509 | ␊ |
510 | void LatexDocVisitor::visitPre(DocPara *) ␊ |
511 | {␊ |
512 | }␊ |
513 | ␊ |
514 | void LatexDocVisitor::visitPost(DocPara *p)␊ |
515 | {␊ |
516 | if (m_hide) return;␊ |
517 | if (!p->isLast() && // omit <p> for last paragraph␊ |
518 | !(p->parent() && // and for parameter sections␊ |
519 | p->parent()->kind()==DocNode::Kind_ParamSect␊ |
520 | )␊ |
521 | ) m_t << endl << endl;␊ |
522 | }␊ |
523 | ␊ |
524 | void LatexDocVisitor::visitPre(DocRoot *)␊ |
525 | {␊ |
526 | }␊ |
527 | ␊ |
528 | void LatexDocVisitor::visitPost(DocRoot *)␊ |
529 | {␊ |
530 | }␊ |
531 | ␊ |
532 | void LatexDocVisitor::visitPre(DocSimpleSect *s)␊ |
533 | {␊ |
534 | if (m_hide) return;␊ |
535 | switch(s->type())␊ |
536 | {␊ |
537 | case DocSimpleSect::See:␊ |
538 | m_t << "\\begin{DoxySeeAlso}{";␊ |
539 | filter(theTranslator->trSeeAlso());␊ |
540 | break;␊ |
541 | case DocSimpleSect::Return:␊ |
542 | m_t << "\\begin{DoxyReturn}{";␊ |
543 | filter(theTranslator->trReturns());␊ |
544 | break;␊ |
545 | case DocSimpleSect::Author:␊ |
546 | m_t << "\\begin{DoxyAuthor}{";␊ |
547 | filter(theTranslator->trAuthor(TRUE,TRUE));␊ |
548 | break;␊ |
549 | case DocSimpleSect::Authors:␊ |
550 | m_t << "\\begin{DoxyAuthor}{";␊ |
551 | filter(theTranslator->trAuthor(TRUE,FALSE));␊ |
552 | break;␊ |
553 | case DocSimpleSect::Version:␊ |
554 | m_t << "\\begin{DoxyVersion}{";␊ |
555 | filter(theTranslator->trVersion());␊ |
556 | break;␊ |
557 | case DocSimpleSect::Since:␊ |
558 | m_t << "\\begin{DoxySince}{";␊ |
559 | filter(theTranslator->trSince());␊ |
560 | break;␊ |
561 | case DocSimpleSect::Date:␊ |
562 | m_t << "\\begin{DoxyDate}{";␊ |
563 | filter(theTranslator->trDate());␊ |
564 | break;␊ |
565 | case DocSimpleSect::Note:␊ |
566 | m_t << "\\begin{DoxyNote}{";␊ |
567 | filter(theTranslator->trNote());␊ |
568 | break;␊ |
569 | case DocSimpleSect::Warning:␊ |
570 | m_t << "\\begin{DoxyWarning}{";␊ |
571 | filter(theTranslator->trWarning());␊ |
572 | break;␊ |
573 | case DocSimpleSect::Pre:␊ |
574 | m_t << "\\begin{DoxyPrecond}{";␊ |
575 | filter(theTranslator->trPrecondition());␊ |
576 | break;␊ |
577 | case DocSimpleSect::Post:␊ |
578 | m_t << "\\begin{DoxyPostcond}{";␊ |
579 | filter(theTranslator->trPostcondition());␊ |
580 | break;␊ |
581 | case DocSimpleSect::Invar:␊ |
582 | m_t << "\\begin{DoxyInvariant}{";␊ |
583 | filter(theTranslator->trInvariant());␊ |
584 | break;␊ |
585 | case DocSimpleSect::Remark:␊ |
586 | m_t << "\\begin{DoxyRemark}{";␊ |
587 | filter(theTranslator->trRemarks());␊ |
588 | break;␊ |
589 | case DocSimpleSect::Attention:␊ |
590 | m_t << "\\begin{DoxyAttention}{";␊ |
591 | filter(theTranslator->trAttention());␊ |
592 | break;␊ |
593 | case DocSimpleSect::User:␊ |
594 | m_t << "\\begin{DoxyParagraph}{";␊ |
595 | break;␊ |
596 | case DocSimpleSect::Rcs: ␊ |
597 | m_t << "\\begin{DoxyParagraph}{";␊ |
598 | break;␊ |
599 | case DocSimpleSect::Unknown: break;␊ |
600 | }␊ |
601 | ␊ |
602 | // special case 1: user defined title␊ |
603 | if (s->type()!=DocSimpleSect::User && s->type()!=DocSimpleSect::Rcs)␊ |
604 | {␊ |
605 | m_t << "}\n";␊ |
606 | }␊ |
607 | else␊ |
608 | {␊ |
609 | m_insideItem=TRUE;␊ |
610 | }␊ |
611 | }␊ |
612 | ␊ |
613 | void LatexDocVisitor::visitPost(DocSimpleSect *s)␊ |
614 | {␊ |
615 | if (m_hide) return;␊ |
616 | switch(s->type())␊ |
617 | {␊ |
618 | case DocSimpleSect::See:␊ |
619 | m_t << "\n\\end{DoxySeeAlso}\n";␊ |
620 | break;␊ |
621 | case DocSimpleSect::Return:␊ |
622 | m_t << "\n\\end{DoxyReturn}\n";␊ |
623 | break;␊ |
624 | case DocSimpleSect::Author:␊ |
625 | m_t << "\n\\end{DoxyAuthor}\n";␊ |
626 | break;␊ |
627 | case DocSimpleSect::Authors:␊ |
628 | m_t << "\n\\end{DoxyAuthor}\n";␊ |
629 | break;␊ |
630 | case DocSimpleSect::Version:␊ |
631 | m_t << "\n\\end{DoxyVersion}\n";␊ |
632 | break;␊ |
633 | case DocSimpleSect::Since:␊ |
634 | m_t << "\n\\end{DoxySince}\n";␊ |
635 | break;␊ |
636 | case DocSimpleSect::Date:␊ |
637 | m_t << "\n\\end{DoxyDate}\n";␊ |
638 | break;␊ |
639 | case DocSimpleSect::Note:␊ |
640 | m_t << "\n\\end{DoxyNote}\n";␊ |
641 | break;␊ |
642 | case DocSimpleSect::Warning:␊ |
643 | m_t << "\n\\end{DoxyWarning}\n";␊ |
644 | break;␊ |
645 | case DocSimpleSect::Pre:␊ |
646 | m_t << "\n\\end{DoxyPrecond}\n";␊ |
647 | break;␊ |
648 | case DocSimpleSect::Post:␊ |
649 | m_t << "\n\\end{DoxyPostcond}\n";␊ |
650 | break;␊ |
651 | case DocSimpleSect::Invar:␊ |
652 | m_t << "\n\\end{DoxyInvariant}\n";␊ |
653 | break;␊ |
654 | case DocSimpleSect::Remark:␊ |
655 | m_t << "\n\\end{DoxyRemark}\n";␊ |
656 | break;␊ |
657 | case DocSimpleSect::Attention:␊ |
658 | m_t << "\n\\end{DoxyAttention}\n";␊ |
659 | break;␊ |
660 | case DocSimpleSect::User:␊ |
661 | m_t << "\n\\end{DoxyParagraph}\n";␊ |
662 | break;␊ |
663 | case DocSimpleSect::Rcs: ␊ |
664 | m_t << "\n\\end{DoxyParagraph}\n";␊ |
665 | break;␊ |
666 | default:␊ |
667 | break;␊ |
668 | }␊ |
669 | }␊ |
670 | ␊ |
671 | void LatexDocVisitor::visitPre(DocTitle *)␊ |
672 | {␊ |
673 | }␊ |
674 | ␊ |
675 | void LatexDocVisitor::visitPost(DocTitle *)␊ |
676 | {␊ |
677 | if (m_hide) return;␊ |
678 | m_insideItem=FALSE;␊ |
679 | m_t << "}\n";␊ |
680 | }␊ |
681 | ␊ |
682 | void LatexDocVisitor::visitPre(DocSimpleList *)␊ |
683 | {␊ |
684 | if (m_hide) return;␊ |
685 | m_t << "\\begin{DoxyItemize}" << endl;␊ |
686 | }␊ |
687 | ␊ |
688 | void LatexDocVisitor::visitPost(DocSimpleList *)␊ |
689 | {␊ |
690 | if (m_hide) return;␊ |
691 | m_t << "\\end{DoxyItemize}" << endl;␊ |
692 | }␊ |
693 | ␊ |
694 | void LatexDocVisitor::visitPre(DocSimpleListItem *)␊ |
695 | {␊ |
696 | if (m_hide) return;␊ |
697 | m_t << "\\item ";␊ |
698 | }␊ |
699 | ␊ |
700 | void LatexDocVisitor::visitPost(DocSimpleListItem *) ␊ |
701 | {␊ |
702 | }␊ |
703 | ␊ |
704 | void LatexDocVisitor::visitPre(DocSection *s)␊ |
705 | {␊ |
706 | if (m_hide) return;␊ |
707 | if (Config_getBool("PDF_HYPERLINKS"))␊ |
708 | {␊ |
709 | m_t << "\\hypertarget{" << s->file() << "_" << s->anchor() << "}{}";␊ |
710 | }␊ |
711 | m_t << "\\" << getSectionName(s->level()) << "{";␊ |
712 | filter(convertCharEntitiesToUTF8(s->title().data()));␊ |
713 | m_t << "}\\label{" << s->file() << "_" << s->anchor() << "}" << endl;␊ |
714 | }␊ |
715 | ␊ |
716 | void LatexDocVisitor::visitPost(DocSection *) ␊ |
717 | {␊ |
718 | }␊ |
719 | ␊ |
720 | void LatexDocVisitor::visitPre(DocHtmlList *s)␊ |
721 | {␊ |
722 | if (m_hide) return;␊ |
723 | if (s->type()==DocHtmlList::Ordered) ␊ |
724 | m_t << "\n\\begin{DoxyEnumerate}";␊ |
725 | else ␊ |
726 | m_t << "\n\\begin{DoxyItemize}";␊ |
727 | }␊ |
728 | ␊ |
729 | void LatexDocVisitor::visitPost(DocHtmlList *s) ␊ |
730 | {␊ |
731 | if (m_hide) return;␊ |
732 | if (s->type()==DocHtmlList::Ordered) ␊ |
733 | m_t << "\n\\end{DoxyEnumerate}";␊ |
734 | else ␊ |
735 | m_t << "\n\\end{DoxyItemize}";␊ |
736 | }␊ |
737 | ␊ |
738 | void LatexDocVisitor::visitPre(DocHtmlListItem *)␊ |
739 | {␊ |
740 | if (m_hide) return;␊ |
741 | m_t << "\n\\item ";␊ |
742 | }␊ |
743 | ␊ |
744 | void LatexDocVisitor::visitPost(DocHtmlListItem *) ␊ |
745 | {␊ |
746 | }␊ |
747 | ␊ |
748 | //void LatexDocVisitor::visitPre(DocHtmlPre *)␊ |
749 | //{␊ |
750 | // m_t << "\\small\\begin{alltt}";␊ |
751 | // m_insidePre=TRUE;␊ |
752 | //}␊ |
753 | ␊ |
754 | //void LatexDocVisitor::visitPost(DocHtmlPre *) ␊ |
755 | //{␊ |
756 | // m_insidePre=FALSE;␊ |
757 | // m_t << "\\end{alltt}\\normalsize " << endl;␊ |
758 | //}␊ |
759 | ␊ |
760 | void LatexDocVisitor::visitPre(DocHtmlDescList *)␊ |
761 | {␊ |
762 | if (m_hide) return;␊ |
763 | m_t << "\n\\begin{DoxyDescription}";␊ |
764 | }␊ |
765 | ␊ |
766 | void LatexDocVisitor::visitPost(DocHtmlDescList *) ␊ |
767 | {␊ |
768 | if (m_hide) return;␊ |
769 | m_t << "\n\\end{DoxyDescription}";␊ |
770 | }␊ |
771 | ␊ |
772 | void LatexDocVisitor::visitPre(DocHtmlDescTitle *)␊ |
773 | {␊ |
774 | if (m_hide) return;␊ |
775 | m_t << "\n\\item[";␊ |
776 | m_insideItem=TRUE;␊ |
777 | }␊ |
778 | ␊ |
779 | void LatexDocVisitor::visitPost(DocHtmlDescTitle *) ␊ |
780 | {␊ |
781 | if (m_hide) return;␊ |
782 | m_insideItem=FALSE;␊ |
783 | m_t << "]";␊ |
784 | }␊ |
785 | ␊ |
786 | void LatexDocVisitor::visitPre(DocHtmlDescData *)␊ |
787 | {␊ |
788 | }␊ |
789 | ␊ |
790 | void LatexDocVisitor::visitPost(DocHtmlDescData *) ␊ |
791 | {␊ |
792 | }␊ |
793 | ␊ |
794 | void LatexDocVisitor::visitPre(DocHtmlTable *t)␊ |
795 | {␊ |
796 | m_rowspanIndices.clear();␊ |
797 | if (m_hide) return;␊ |
798 | if (t->hasCaption()) ␊ |
799 | {␊ |
800 | m_t << "\\begin{table}[h]";␊ |
801 | }␊ |
802 | m_t << "\\begin{TabularC}{" << t->numCols() << "}\n\\hline\n";␊ |
803 | }␊ |
804 | ␊ |
805 | void LatexDocVisitor::visitPost(DocHtmlTable *t) ␊ |
806 | {␊ |
807 | if (m_hide) return;␊ |
808 | if (t->hasCaption())␊ |
809 | {␊ |
810 | m_t << "\\end{table}\n";␊ |
811 | }␊ |
812 | else␊ |
813 | {␊ |
814 | m_t << "\\end{TabularC}\n";␊ |
815 | }␊ |
816 | }␊ |
817 | ␊ |
818 | void LatexDocVisitor::visitPre(DocHtmlCaption *)␊ |
819 | {␊ |
820 | if (m_hide) return;␊ |
821 | m_t << "\\end{TabularC}\n\\centering\n\\caption{";␊ |
822 | }␊ |
823 | ␊ |
824 | void LatexDocVisitor::visitPost(DocHtmlCaption *) ␊ |
825 | {␊ |
826 | if (m_hide) return;␊ |
827 | m_t << "}\n";␊ |
828 | }␊ |
829 | ␊ |
830 | void LatexDocVisitor::visitPre(DocHtmlRow *)␊ |
831 | {␊ |
832 | m_currentColumn = 0;␊ |
833 | }␊ |
834 | ␊ |
835 | void LatexDocVisitor::visitPost(DocHtmlRow *) ␊ |
836 | {␊ |
837 | if (m_hide) return;␊ |
838 | ␊ |
839 | m_t << "\\\\";␊ |
840 | ␊ |
841 | QMap<int, int>::Iterator it;␊ |
842 | int col = 1;␊ |
843 | for (it = m_rowspanIndices.begin(); it != m_rowspanIndices.end(); ++it) ␊ |
844 | {␊ |
845 | it.data()--;␊ |
846 | if (it.data () <= 0)␊ |
847 | m_rowspanIndices.remove (it);␊ |
848 | else if (0 < it.data() - col)␊ |
849 | m_t << "\\cline{" << col << "-" << it.data() - col << "}";␊ |
850 | ␊ |
851 | col = 1 + it.data ();␊ |
852 | }␊ |
853 | ␊ |
854 | if (col <= m_currentColumn)␊ |
855 | m_t << "\\cline{" << col << "-" << m_currentColumn << "}";␊ |
856 | ␊ |
857 | m_t << "\n";␊ |
858 | }␊ |
859 | ␊ |
860 | void LatexDocVisitor::visitPre(DocHtmlCell *cell)␊ |
861 | {␊ |
862 | if (m_hide) return;␊ |
863 | ␊ |
864 | m_currentColumn++;␊ |
865 | //Skip columns that span from above.␊ |
866 | QMap<int, int>::Iterator it = m_rowspanIndices.find(m_currentColumn);␊ |
867 | while (0 < it.data() && it != m_rowspanIndices.end())␊ |
868 | {␊ |
869 | m_t << "&";␊ |
870 | m_currentColumn++;␊ |
871 | it++;␊ |
872 | }␊ |
873 | ␊ |
874 | int rs = rowspan(cell);␊ |
875 | if (0 < rs)␊ |
876 | {␊ |
877 | m_inRowspan = TRUE;␊ |
878 | m_rowspanIndices[m_currentColumn] = rs;␊ |
879 | m_t << "\\multirow{" << rs << "}{\\linewidth}{";␊ |
880 | }␊ |
881 | }␊ |
882 | ␊ |
883 | void LatexDocVisitor::visitPost(DocHtmlCell *c) ␊ |
884 | {␊ |
885 | if (m_hide) return;␊ |
886 | if (m_inRowspan)␊ |
887 | {␊ |
888 | m_inRowspan = FALSE;␊ |
889 | m_t << "}";␊ |
890 | }␊ |
891 | if (!c->isLast()) m_t << "&";␊ |
892 | }␊ |
893 | ␊ |
894 | void LatexDocVisitor::visitPre(DocInternal *)␊ |
895 | {␊ |
896 | if (m_hide) return;␊ |
897 | //m_t << "\\begin{DoxyInternal}{";␊ |
898 | //filter(theTranslator->trForInternalUseOnly());␊ |
899 | //m_t << "}\n";␊ |
900 | }␊ |
901 | ␊ |
902 | void LatexDocVisitor::visitPost(DocInternal *) ␊ |
903 | {␊ |
904 | if (m_hide) return;␊ |
905 | //m_t << "\\end{DoxyInternal}" << endl;␊ |
906 | }␊ |
907 | ␊ |
908 | void LatexDocVisitor::visitPre(DocHRef *href)␊ |
909 | {␊ |
910 | if (m_hide) return;␊ |
911 | if (Config_getBool("PDF_HYPERLINKS"))␊ |
912 | {␊ |
913 | m_t << "\\href{";␊ |
914 | m_t << href->url();␊ |
915 | m_t << "}";␊ |
916 | }␊ |
917 | m_t << "{\\tt ";␊ |
918 | }␊ |
919 | ␊ |
920 | void LatexDocVisitor::visitPost(DocHRef *) ␊ |
921 | {␊ |
922 | if (m_hide) return;␊ |
923 | m_t << "}";␊ |
924 | }␊ |
925 | ␊ |
926 | void LatexDocVisitor::visitPre(DocHtmlHeader *header)␊ |
927 | {␊ |
928 | if (m_hide) return;␊ |
929 | m_t << "\\" << getSectionName(header->level()) << "*{";␊ |
930 | }␊ |
931 | ␊ |
932 | void LatexDocVisitor::visitPost(DocHtmlHeader *) ␊ |
933 | {␊ |
934 | if (m_hide) return;␊ |
935 | m_t << "}";␊ |
936 | }␊ |
937 | ␊ |
938 | void LatexDocVisitor::visitPre(DocImage *img)␊ |
939 | {␊ |
940 | if (img->type()==DocImage::Latex)␊ |
941 | {␊ |
942 | if (m_hide) return;␊ |
943 | if (img->hasCaption())␊ |
944 | {␊ |
945 | m_t << "\n\\begin{DoxyImage}\n";␊ |
946 | }␊ |
947 | else␊ |
948 | {␊ |
949 | m_t << "\n\\begin{DoxyImageNoCaption}\n"␊ |
950 | " \\mbox{";␊ |
951 | }␊ |
952 | QCString gfxName = img->name();␊ |
953 | if (gfxName.right(4)==".eps" || gfxName.right(4)==".pdf")␊ |
954 | {␊ |
955 | gfxName=gfxName.left(gfxName.length()-4);␊ |
956 | }␊ |
957 | m_t << "\\includegraphics";␊ |
958 | if (!img->width().isEmpty())␊ |
959 | {␊ |
960 | m_t << "[width=" << img->width() << "]";␊ |
961 | }␊ |
962 | else if (!img->height().isEmpty())␊ |
963 | {␊ |
964 | m_t << "[height=" << img->height() << "]";␊ |
965 | }␊ |
966 | m_t << "{" << gfxName << "}";␊ |
967 | if (img->hasCaption())␊ |
968 | {␊ |
969 | m_t << "\n\\caption{";␊ |
970 | }␊ |
971 | }␊ |
972 | else // other format -> skip␊ |
973 | {␊ |
974 | pushEnabled();␊ |
975 | m_hide=TRUE;␊ |
976 | }␊ |
977 | }␊ |
978 | ␊ |
979 | void LatexDocVisitor::visitPost(DocImage *img) ␊ |
980 | {␊ |
981 | if (img->type()==DocImage::Latex)␊ |
982 | {␊ |
983 | if (m_hide) return;␊ |
984 | m_t << "}\n"; // end mbox or caption␊ |
985 | if (img->hasCaption())␊ |
986 | {␊ |
987 | m_t << "\\end{DoxyImage}\n";␊ |
988 | }␊ |
989 | else{␊ |
990 | m_t << "\\end{DoxyImageNoCaption}\n";␊ |
991 | }␊ |
992 | }␊ |
993 | else // other format␊ |
994 | {␊ |
995 | popEnabled();␊ |
996 | }␊ |
997 | }␊ |
998 | ␊ |
999 | void LatexDocVisitor::visitPre(DocDotFile *df)␊ |
1000 | {␊ |
1001 | if (m_hide) return;␊ |
1002 | startDotFile(df->file(),df->width(),df->height(),df->hasCaption());␊ |
1003 | }␊ |
1004 | ␊ |
1005 | void LatexDocVisitor::visitPost(DocDotFile *df) ␊ |
1006 | {␊ |
1007 | if (m_hide) return;␊ |
1008 | endDotFile(df->hasCaption());␊ |
1009 | }␊ |
1010 | void LatexDocVisitor::visitPre(DocMscFile *df)␊ |
1011 | {␊ |
1012 | if (m_hide) return;␊ |
1013 | startMscFile(df->file(),df->width(),df->height(),df->hasCaption());␊ |
1014 | }␊ |
1015 | ␊ |
1016 | void LatexDocVisitor::visitPost(DocMscFile *df) ␊ |
1017 | {␊ |
1018 | if (m_hide) return;␊ |
1019 | endMscFile(df->hasCaption());␊ |
1020 | }␊ |
1021 | void LatexDocVisitor::visitPre(DocLink *lnk)␊ |
1022 | {␊ |
1023 | if (m_hide) return;␊ |
1024 | startLink(lnk->ref(),lnk->file(),lnk->anchor());␊ |
1025 | }␊ |
1026 | ␊ |
1027 | void LatexDocVisitor::visitPost(DocLink *lnk) ␊ |
1028 | {␊ |
1029 | if (m_hide) return;␊ |
1030 | endLink(lnk->ref(),lnk->file(),lnk->anchor());␊ |
1031 | }␊ |
1032 | ␊ |
1033 | void LatexDocVisitor::visitPre(DocRef *ref)␊ |
1034 | {␊ |
1035 | if (m_hide) return;␊ |
1036 | if (!ref->file().isEmpty()) startLink(ref->ref(),ref->file(),ref->anchor());␊ |
1037 | if (!ref->hasLinkText()) filter(ref->targetTitle());␊ |
1038 | }␊ |
1039 | ␊ |
1040 | void LatexDocVisitor::visitPost(DocRef *ref) ␊ |
1041 | {␊ |
1042 | if (m_hide) return;␊ |
1043 | if (!ref->file().isEmpty()) endLink(ref->ref(),ref->file(),ref->anchor());␊ |
1044 | }␊ |
1045 | ␊ |
1046 | void LatexDocVisitor::visitPre(DocSecRefItem *)␊ |
1047 | {␊ |
1048 | if (m_hide) return;␊ |
1049 | m_t << "\\item \\contentsline{section}{";␊ |
1050 | }␊ |
1051 | ␊ |
1052 | void LatexDocVisitor::visitPost(DocSecRefItem *ref) ␊ |
1053 | {␊ |
1054 | if (m_hide) return;␊ |
1055 | m_t << "}{\\ref{" << ref->file() << "_" << ref->anchor() << "}}{}" << endl;␊ |
1056 | }␊ |
1057 | ␊ |
1058 | void LatexDocVisitor::visitPre(DocSecRefList *)␊ |
1059 | {␊ |
1060 | if (m_hide) return;␊ |
1061 | m_t << "\\footnotesize" << endl;␊ |
1062 | m_t << "\\begin{multicols}{2}" << endl;␊ |
1063 | m_t << "\\begin{DoxyCompactList}" << endl;␊ |
1064 | }␊ |
1065 | ␊ |
1066 | void LatexDocVisitor::visitPost(DocSecRefList *) ␊ |
1067 | {␊ |
1068 | if (m_hide) return;␊ |
1069 | m_t << "\\end{DoxyCompactList}" << endl;␊ |
1070 | m_t << "\\end{multicols}" << endl;␊ |
1071 | m_t << "\\normalsize" << endl;␊ |
1072 | }␊ |
1073 | ␊ |
1074 | //void LatexDocVisitor::visitPre(DocLanguage *l)␊ |
1075 | //{␊ |
1076 | // QCString langId = Config_getEnum("OUTPUT_LANGUAGE");␊ |
1077 | // if (l->id().lower()!=langId.lower())␊ |
1078 | // {␊ |
1079 | // pushEnabled();␊ |
1080 | // m_hide = TRUE;␊ |
1081 | // }␊ |
1082 | //}␊ |
1083 | //␊ |
1084 | //void LatexDocVisitor::visitPost(DocLanguage *l) ␊ |
1085 | //{␊ |
1086 | // QCString langId = Config_getEnum("OUTPUT_LANGUAGE");␊ |
1087 | // if (l->id().lower()!=langId.lower())␊ |
1088 | // {␊ |
1089 | // popEnabled();␊ |
1090 | // }␊ |
1091 | //}␊ |
1092 | ␊ |
1093 | void LatexDocVisitor::visitPre(DocParamSect *s)␊ |
1094 | {␊ |
1095 | if (m_hide) return;␊ |
1096 | bool hasInOutSpecs = s->hasInOutSpecifier();␊ |
1097 | bool hasTypeSpecs = s->hasTypeSpecifier();␊ |
1098 | switch(s->type())␊ |
1099 | {␊ |
1100 | case DocParamSect::Param:␊ |
1101 | m_t << "\n\\begin{DoxyParams}";␊ |
1102 | if (hasInOutSpecs && hasTypeSpecs) m_t << "[2]"; // 2 extra cols␊ |
1103 | else if (hasInOutSpecs || hasTypeSpecs) m_t << "[1]"; // 1 extra col␊ |
1104 | m_t << "{";␊ |
1105 | filter(theTranslator->trParameters());␊ |
1106 | break;␊ |
1107 | case DocParamSect::RetVal:␊ |
1108 | m_t << "\n\\begin{DoxyRetVals}{";␊ |
1109 | filter(theTranslator->trReturnValues());␊ |
1110 | break;␊ |
1111 | case DocParamSect::Exception: ␊ |
1112 | m_t << "\n\\begin{DoxyExceptions}{";␊ |
1113 | filter(theTranslator->trExceptions());␊ |
1114 | break;␊ |
1115 | case DocParamSect::TemplateParam: ␊ |
1116 | /* TODO: add this ␊ |
1117 | filter(theTranslator->trTemplateParam()); break;␊ |
1118 | */␊ |
1119 | m_t << "\n\\begin{DoxyTemplParams}{";␊ |
1120 | filter("Template Parameters");␊ |
1121 | break;␊ |
1122 | default:␊ |
1123 | ASSERT(0);␊ |
1124 | }␊ |
1125 | m_t << "}\n";␊ |
1126 | }␊ |
1127 | ␊ |
1128 | void LatexDocVisitor::visitPost(DocParamSect *s)␊ |
1129 | {␊ |
1130 | if (m_hide) return;␊ |
1131 | switch(s->type())␊ |
1132 | {␊ |
1133 | case DocParamSect::Param:␊ |
1134 | m_t << "\\end{DoxyParams}\n";␊ |
1135 | break;␊ |
1136 | case DocParamSect::RetVal:␊ |
1137 | m_t << "\\end{DoxyRetVals}\n";␊ |
1138 | break;␊ |
1139 | case DocParamSect::Exception: ␊ |
1140 | m_t << "\\end{DoxyExceptions}\n";␊ |
1141 | break;␊ |
1142 | case DocParamSect::TemplateParam: ␊ |
1143 | m_t << "\\end{DoxyTemplParams}\n";␊ |
1144 | break;␊ |
1145 | default:␊ |
1146 | ASSERT(0);␊ |
1147 | }␊ |
1148 | }␊ |
1149 | ␊ |
1150 | void LatexDocVisitor::visitPre(DocParamList *pl)␊ |
1151 | {␊ |
1152 | if (m_hide) return;␊ |
1153 | DocParamSect::Type parentType = DocParamSect::Unknown;␊ |
1154 | DocParamSect *sect = 0;␊ |
1155 | if (pl->parent() && pl->parent()->kind()==DocNode::Kind_ParamSect)␊ |
1156 | {␊ |
1157 | parentType = ((DocParamSect*)pl->parent())->type();␊ |
1158 | sect=(DocParamSect*)pl->parent();␊ |
1159 | }␊ |
1160 | bool useTable = parentType==DocParamSect::Param ||␊ |
1161 | parentType==DocParamSect::RetVal ||␊ |
1162 | parentType==DocParamSect::Exception ||␊ |
1163 | parentType==DocParamSect::TemplateParam;␊ |
1164 | if (!useTable)␊ |
1165 | {␊ |
1166 | m_t << "\\item[";␊ |
1167 | }␊ |
1168 | if (sect && sect->hasInOutSpecifier())␊ |
1169 | {␊ |
1170 | if (pl->direction()!=DocParamSect::Unspecified)␊ |
1171 | {␊ |
1172 | m_t << "\\mbox{\\tt ";␊ |
1173 | if (pl->direction()==DocParamSect::In)␊ |
1174 | {␊ |
1175 | m_t << "in";␊ |
1176 | }␊ |
1177 | else if (pl->direction()==DocParamSect::Out)␊ |
1178 | {␊ |
1179 | m_t << "out";␊ |
1180 | }␊ |
1181 | else if (pl->direction()==DocParamSect::InOut)␊ |
1182 | {␊ |
1183 | m_t << "in,out";␊ |
1184 | }␊ |
1185 | m_t << "} ";␊ |
1186 | }␊ |
1187 | if (useTable) m_t << " & ";␊ |
1188 | }␊ |
1189 | if (sect && sect->hasTypeSpecifier())␊ |
1190 | {␊ |
1191 | QListIterator<DocNode> li(pl->paramTypes());␊ |
1192 | DocNode *type;␊ |
1193 | bool first=TRUE;␊ |
1194 | for (li.toFirst();(type=li.current());++li)␊ |
1195 | {␊ |
1196 | if (!first) m_t << " | "; else first=FALSE;␊ |
1197 | if (type->kind()==DocNode::Kind_Word)␊ |
1198 | {␊ |
1199 | visit((DocWord*)type); ␊ |
1200 | }␊ |
1201 | else if (type->kind()==DocNode::Kind_LinkedWord)␊ |
1202 | {␊ |
1203 | visit((DocLinkedWord*)type); ␊ |
1204 | }␊ |
1205 | }␊ |
1206 | if (useTable) m_t << " & ";␊ |
1207 | }␊ |
1208 | m_t << "{\\em ";␊ |
1209 | //QStrListIterator li(pl->parameters());␊ |
1210 | //const char *s;␊ |
1211 | QListIterator<DocNode> li(pl->parameters());␊ |
1212 | DocNode *param;␊ |
1213 | bool first=TRUE;␊ |
1214 | for (li.toFirst();(param=li.current());++li)␊ |
1215 | {␊ |
1216 | if (!first) m_t << ","; else first=FALSE;␊ |
1217 | m_insideItem=TRUE;␊ |
1218 | if (param->kind()==DocNode::Kind_Word)␊ |
1219 | {␊ |
1220 | visit((DocWord*)param); ␊ |
1221 | }␊ |
1222 | else if (param->kind()==DocNode::Kind_LinkedWord)␊ |
1223 | {␊ |
1224 | visit((DocLinkedWord*)param); ␊ |
1225 | }␊ |
1226 | m_insideItem=FALSE;␊ |
1227 | }␊ |
1228 | m_t << "}";␊ |
1229 | if (useTable)␊ |
1230 | {␊ |
1231 | m_t << " & ";␊ |
1232 | }␊ |
1233 | else␊ |
1234 | {␊ |
1235 | m_t << "]";␊ |
1236 | }␊ |
1237 | }␊ |
1238 | ␊ |
1239 | void LatexDocVisitor::visitPost(DocParamList *pl)␊ |
1240 | {␊ |
1241 | if (m_hide) return;␊ |
1242 | DocParamSect::Type parentType = DocParamSect::Unknown;␊ |
1243 | if (pl->parent() && pl->parent()->kind()==DocNode::Kind_ParamSect)␊ |
1244 | {␊ |
1245 | parentType = ((DocParamSect*)pl->parent())->type();␊ |
1246 | }␊ |
1247 | bool useTable = parentType==DocParamSect::Param ||␊ |
1248 | parentType==DocParamSect::RetVal ||␊ |
1249 | parentType==DocParamSect::Exception ||␊ |
1250 | parentType==DocParamSect::TemplateParam;␊ |
1251 | if (useTable)␊ |
1252 | {␊ |
1253 | m_t << "\\\\" << endl␊ |
1254 | << "\\hline" << endl;␊ |
1255 | }␊ |
1256 | }␊ |
1257 | ␊ |
1258 | void LatexDocVisitor::visitPre(DocXRefItem *x)␊ |
1259 | {␊ |
1260 | if (m_hide) return;␊ |
1261 | m_t << "\\begin{Desc}" << endl;␊ |
1262 | bool anonymousEnum = x->file()=="@";␊ |
1263 | m_t << "\\item[";␊ |
1264 | if (Config_getBool("PDF_HYPERLINKS") && !anonymousEnum)␊ |
1265 | {␊ |
1266 | m_t << "\\hyperlink{" << stripPath(x->file()) << "_" << x->anchor() << "}{";␊ |
1267 | }␊ |
1268 | else␊ |
1269 | {␊ |
1270 | m_t << "{\\bf ";␊ |
1271 | }␊ |
1272 | m_insideItem=TRUE;␊ |
1273 | filter(x->title());␊ |
1274 | m_insideItem=FALSE;␊ |
1275 | m_t << "}]";␊ |
1276 | }␊ |
1277 | ␊ |
1278 | void LatexDocVisitor::visitPost(DocXRefItem *)␊ |
1279 | {␊ |
1280 | if (m_hide) return;␊ |
1281 | m_t << "\\end{Desc}" << endl;␊ |
1282 | }␊ |
1283 | ␊ |
1284 | void LatexDocVisitor::visitPre(DocInternalRef *ref)␊ |
1285 | {␊ |
1286 | if (m_hide) return;␊ |
1287 | startLink(0,ref->file(),ref->anchor());␊ |
1288 | }␊ |
1289 | ␊ |
1290 | void LatexDocVisitor::visitPost(DocInternalRef *ref) ␊ |
1291 | {␊ |
1292 | if (m_hide) return;␊ |
1293 | endLink(0,ref->file(),ref->anchor());␊ |
1294 | }␊ |
1295 | ␊ |
1296 | void LatexDocVisitor::visitPre(DocCopy *)␊ |
1297 | {␊ |
1298 | }␊ |
1299 | ␊ |
1300 | void LatexDocVisitor::visitPost(DocCopy *)␊ |
1301 | {␊ |
1302 | }␊ |
1303 | ␊ |
1304 | void LatexDocVisitor::visitPre(DocText *)␊ |
1305 | {␊ |
1306 | }␊ |
1307 | ␊ |
1308 | void LatexDocVisitor::visitPost(DocText *)␊ |
1309 | {␊ |
1310 | }␊ |
1311 | ␊ |
1312 | void LatexDocVisitor::filter(const char *str)␊ |
1313 | { ␊ |
1314 | filterLatexString(m_t,str,m_insideTabbing,m_insidePre,m_insideItem);␊ |
1315 | }␊ |
1316 | ␊ |
1317 | void LatexDocVisitor::startLink(const QCString &ref,const QCString &file,const QCString &anchor)␊ |
1318 | {␊ |
1319 | if (ref.isEmpty() && Config_getBool("PDF_HYPERLINKS")) // internal PDF link ␊ |
1320 | {␊ |
1321 | if (ref.isEmpty()) {␊ |
1322 | m_t << "\\hyperlink{";␊ |
1323 | if (!file.isEmpty()) m_t << stripPath(file);␊ |
1324 | if (!file.isEmpty() && !anchor.isEmpty()) m_t << "_";␊ |
1325 | if (!anchor.isEmpty()) m_t << anchor;␊ |
1326 | m_t << "}{";␊ |
1327 | }␊ |
1328 | else␊ |
1329 | {␊ |
1330 | QCString *dest;␊ |
1331 | m_t << "\\href{";␊ |
1332 | if ((dest=Doxygen::tagDestinationDict[ref])) m_t << *dest << "/";␊ |
1333 | if (!file.isEmpty()) m_t << file << Doxygen::htmlFileExtension;␊ |
1334 | if (!anchor.isEmpty()) m_t << "#" << anchor;␊ |
1335 | m_t << "}{";␊ |
1336 | }␊ |
1337 | }␊ |
1338 | else if (ref.isEmpty()) // internal non-PDF link␊ |
1339 | {␊ |
1340 | m_t << "\\doxyref{";␊ |
1341 | }␊ |
1342 | else // external link␊ |
1343 | { ␊ |
1344 | m_t << "{\\bf ";␊ |
1345 | }␊ |
1346 | }␊ |
1347 | ␊ |
1348 | void LatexDocVisitor::endLink(const QCString &ref,const QCString &file,const QCString &anchor)␊ |
1349 | {␊ |
1350 | m_t << "}";␊ |
1351 | if (ref.isEmpty() && !Config_getBool("PDF_HYPERLINKS"))␊ |
1352 | {␊ |
1353 | m_t << "{"; ␊ |
1354 | filter(theTranslator->trPageAbbreviation());␊ |
1355 | m_t << "}{" << file;␊ |
1356 | if (!anchor.isEmpty()) m_t << "_" << anchor;␊ |
1357 | m_t << "}";␊ |
1358 | }␊ |
1359 | }␊ |
1360 | ␊ |
1361 | void LatexDocVisitor::pushEnabled()␊ |
1362 | {␊ |
1363 | m_enabled.push(new bool(m_hide));␊ |
1364 | }␊ |
1365 | ␊ |
1366 | void LatexDocVisitor::popEnabled()␊ |
1367 | {␊ |
1368 | bool *v=m_enabled.pop();␊ |
1369 | ASSERT(v!=0);␊ |
1370 | m_hide = *v;␊ |
1371 | delete v;␊ |
1372 | }␊ |
1373 | ␊ |
1374 | void LatexDocVisitor::startDotFile(const QCString &fileName,␊ |
1375 | const QCString &width,␊ |
1376 | const QCString &height,␊ |
1377 | bool hasCaption␊ |
1378 | )␊ |
1379 | {␊ |
1380 | QCString baseName=fileName;␊ |
1381 | int i;␊ |
1382 | if ((i=baseName.findRev('/'))!=-1)␊ |
1383 | {␊ |
1384 | baseName=baseName.right(baseName.length()-i-1);␊ |
1385 | } ␊ |
1386 | if ((i=baseName.find('.'))!=-1)␊ |
1387 | {␊ |
1388 | baseName=baseName.left(i);␊ |
1389 | }␊ |
1390 | baseName.prepend("dot_");␊ |
1391 | QCString outDir = Config_getString("LATEX_OUTPUT");␊ |
1392 | QCString name = fileName;␊ |
1393 | writeDotGraphFromFile(name,outDir,baseName,EPS);␊ |
1394 | if (hasCaption)␊ |
1395 | {␊ |
1396 | m_t << "\n\\begin{DoxyImage}\n";␊ |
1397 | }␊ |
1398 | else␊ |
1399 | {␊ |
1400 | m_t << "\n\\begin{DoxyImageNoCaption}\n"␊ |
1401 | " \\mbox{";␊ |
1402 | }␊ |
1403 | m_t << "\\includegraphics";␊ |
1404 | if (!width.isEmpty())␊ |
1405 | {␊ |
1406 | m_t << "[width=" << width << "]";␊ |
1407 | }␊ |
1408 | else if (!height.isEmpty())␊ |
1409 | {␊ |
1410 | m_t << "[height=" << height << "]";␊ |
1411 | }␊ |
1412 | else␊ |
1413 | {␊ |
1414 | m_t << "[width=\\textwidth]";␊ |
1415 | }␊ |
1416 | m_t << "{" << baseName << "}";␊ |
1417 | ␊ |
1418 | if (hasCaption)␊ |
1419 | {␊ |
1420 | m_t << "\n\\caption{";␊ |
1421 | }␊ |
1422 | }␊ |
1423 | ␊ |
1424 | void LatexDocVisitor::endDotFile(bool hasCaption)␊ |
1425 | {␊ |
1426 | if (m_hide) return;␊ |
1427 | m_t << "}\n"; // end caption or mbox␊ |
1428 | if (hasCaption)␊ |
1429 | {␊ |
1430 | m_t << "\\end{DoxyImage}\n";␊ |
1431 | }␊ |
1432 | else␊ |
1433 | {␊ |
1434 | m_t << "\\end{DoxyImageNoCaption}\n";␊ |
1435 | }␊ |
1436 | }␊ |
1437 | ␊ |
1438 | void LatexDocVisitor::startMscFile(const QCString &fileName,␊ |
1439 | const QCString &width,␊ |
1440 | const QCString &height,␊ |
1441 | bool hasCaption␊ |
1442 | )␊ |
1443 | {␊ |
1444 | QCString baseName=fileName;␊ |
1445 | int i;␊ |
1446 | if ((i=baseName.findRev('/'))!=-1)␊ |
1447 | {␊ |
1448 | baseName=baseName.right(baseName.length()-i-1);␊ |
1449 | } ␊ |
1450 | if ((i=baseName.find('.'))!=-1)␊ |
1451 | {␊ |
1452 | baseName=baseName.left(i);␊ |
1453 | }␊ |
1454 | baseName.prepend("msc_");␊ |
1455 | ␊ |
1456 | QCString outDir = Config_getString("LATEX_OUTPUT");␊ |
1457 | QCString name = fileName;␊ |
1458 | writeMscGraphFromFile(name,outDir,baseName,MSC_EPS); ␊ |
1459 | if (hasCaption)␊ |
1460 | {␊ |
1461 | m_t << "\n\\begin{DoxyImage}\n";␊ |
1462 | }␊ |
1463 | else␊ |
1464 | {␊ |
1465 | m_t << "\n\\begin{DoxyImageNoCaption}\n"␊ |
1466 | " \\mbox{";␊ |
1467 | }␊ |
1468 | m_t << "\\includegraphics";␊ |
1469 | if (!width.isEmpty())␊ |
1470 | {␊ |
1471 | m_t << "[width=" << width << "]";␊ |
1472 | }␊ |
1473 | else if (!height.isEmpty())␊ |
1474 | {␊ |
1475 | m_t << "[height=" << height << "]";␊ |
1476 | }␊ |
1477 | else␊ |
1478 | {␊ |
1479 | m_t << "[width=\\textwidth]";␊ |
1480 | }␊ |
1481 | m_t << "{" << baseName << "}";␊ |
1482 | ␊ |
1483 | if (hasCaption)␊ |
1484 | {␊ |
1485 | m_t << "\n\\caption{";␊ |
1486 | }␊ |
1487 | }␊ |
1488 | ␊ |
1489 | void LatexDocVisitor::endMscFile(bool hasCaption)␊ |
1490 | {␊ |
1491 | if (m_hide) return;␊ |
1492 | m_t << "}\n"; // end caption or mbox␊ |
1493 | if (hasCaption)␊ |
1494 | {␊ |
1495 | m_t << "\\end{DoxyImage}\n";␊ |
1496 | }␊ |
1497 | else␊ |
1498 | {␊ |
1499 | m_t << "\\end{DoxyImageNoCaption}\n";␊ |
1500 | }␊ |
1501 | }␊ |
1502 | ␊ |
1503 | ␊ |
1504 | void LatexDocVisitor::writeMscFile(const QCString &baseName)␊ |
1505 | {␊ |
1506 | QCString shortName = baseName;␊ |
1507 | int i;␊ |
1508 | if ((i=shortName.findRev('/'))!=-1)␊ |
1509 | {␊ |
1510 | shortName=shortName.right(shortName.length()-i-1);␊ |
1511 | } ␊ |
1512 | QCString outDir = Config_getString("LATEX_OUTPUT");␊ |
1513 | writeMscGraphFromFile(baseName,outDir,shortName,MSC_EPS);␊ |
1514 | m_t << "\n\\begin{DoxyImageNoCaption}"␊ |
1515 | " \\mbox{\\includegraphics";␊ |
1516 | m_t << "{" << shortName << "}";␊ |
1517 | m_t << "}\n"; // end mbox␊ |
1518 | m_t << "\\end{DoxyImageNoCaption}\n";␊ |
1519 | }␊ |
1520 | ␊ |
1521 |