1 /******************************************************************************
6 * Copyright (C) 1997-2014 by Dimitri van Heesch.
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.
14 * Documents produced by Doxygen are derivative works derived from the
15 * input used in their production; they are not affected by this license.
18 #include "htmlattrib.h"
19 #include <qfileinfo.h>
20 #include "latexdocvisitor.h"
21 #include "docparser.h"
24 #include "outputgen.h"
28 #include "parserintf.h"
34 #include "htmlentity.h"
37 static QCString escapeLabelName(const char *s)
48 case '%': result+="\\%"; break;
49 case '|': result+="\\texttt{\"|}"; break;
50 case '!': result+="\"!"; break;
51 case '{': result+="\\lcurly{}"; break;
52 case '}': result+="\\rcurly{}"; break;
53 case '~': result+="````~"; break; // to get it a bit better in index together with other special characters
61 const int maxLevels=5;
62 static const char *secLabels[maxLevels] =
63 { "section","subsection","subsubsection","paragraph","subparagraph" };
65 static const char *getSectionName(int level)
67 static bool compactLatex = Config_getBool("COMPACT_LATEX");
69 if (compactLatex) l++;
70 if (Doxygen::insideMainPage) l--;
71 return secLabels[QMIN(maxLevels-1,l)];
74 QCString LatexDocVisitor::escapeMakeIndexChars(const char *s)
78 char str[2]; str[1]=0;
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 case '{': m_t << "\\lcurly{}"; break;
93 case '}': m_t << "\\rcurly{}"; break;
94 default: str[0]=c; filter(str); break;
102 LatexDocVisitor::LatexDocVisitor(FTextStream &t,CodeOutputInterface &ci,
103 const char *langExt,bool insideTabbing)
104 : DocVisitor(DocVisitor_Latex), m_t(t), m_ci(ci), m_insidePre(FALSE),
105 m_insideItem(FALSE), m_hide(FALSE), m_insideTabbing(insideTabbing),
106 m_insideTable(FALSE), m_langExt(langExt), m_currentColumn(0),
107 m_inRowspan(FALSE), m_inColspan(FALSE)
109 m_rowSpans.setAutoDelete(TRUE);
112 //--------------------------------------
113 // visitor functions for leaf nodes
114 //--------------------------------------
116 void LatexDocVisitor::visit(DocWord *w)
122 void LatexDocVisitor::visit(DocLinkedWord *w)
125 startLink(w->ref(),w->file(),w->anchor());
127 endLink(w->ref(),w->file(),w->anchor());
130 void LatexDocVisitor::visit(DocWhiteSpace *w)
143 void LatexDocVisitor::visit(DocSymbol *s)
146 const char *res = HtmlEntityMapper::instance()->latex(s->symbol());
149 if (((s->symbol() == DocSymbol::Sym_lt) || (s->symbol() == DocSymbol::Sym_Less))&& (!m_insidePre))
153 else if (((s->symbol() == DocSymbol::Sym_gt) || (s->symbol() == DocSymbol::Sym_Greater)) && (!m_insidePre))
164 err("LaTeX: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol(),TRUE));
168 void LatexDocVisitor::visit(DocURL *u)
171 if (Config_getBool("PDF_HYPERLINKS"))
174 if (u->isEmail()) m_t << "mailto:";
175 m_t << u->url() << "}";
182 void LatexDocVisitor::visit(DocLineBreak *)
185 m_t << "~\\newline\n";
188 void LatexDocVisitor::visit(DocHorRuler *)
194 void LatexDocVisitor::visit(DocStyleChange *s)
199 case DocStyleChange::Bold:
200 if (s->enable()) m_t << "{\\bfseries "; else m_t << "}";
202 case DocStyleChange::Italic:
203 if (s->enable()) m_t << "{\\itshape "; else m_t << "}";
205 case DocStyleChange::Code:
206 if (s->enable()) m_t << "{\\ttfamily "; else m_t << "}";
208 case DocStyleChange::Subscript:
209 if (s->enable()) m_t << "\\textsubscript{"; else m_t << "}";
211 case DocStyleChange::Superscript:
212 if (s->enable()) m_t << "\\textsuperscript{"; else m_t << "}";
214 case DocStyleChange::Center:
215 if (s->enable()) m_t << "\\begin{center}"; else m_t << "\\end{center} ";
217 case DocStyleChange::Small:
218 if (s->enable()) m_t << "\n\\footnotesize "; else m_t << "\n\\normalsize ";
220 case DocStyleChange::Preformatted:
223 m_t << "\n\\begin{DoxyPre}";
229 m_t << "\\end{DoxyPre}\n";
232 case DocStyleChange::Div: /* HTML only */ break;
233 case DocStyleChange::Span: /* HTML only */ break;
237 void LatexDocVisitor::visit(DocVerbatim *s)
240 QCString lang = m_langExt;
241 if (!s->language().isEmpty()) // explicit language setting
243 lang = s->language();
245 SrcLangExt langExt = getLanguageFromFileName(lang);
248 case DocVerbatim::Code:
250 m_t << "\n\\begin{DoxyCode}\n";
251 Doxygen::parserManager->getParser(lang)
252 ->parseCode(m_ci,s->context(),s->text(),langExt,
253 s->isExample(),s->exampleFile());
254 m_t << "\\end{DoxyCode}\n";
257 case DocVerbatim::Verbatim:
258 m_t << "\\begin{DoxyVerb}";
260 m_t << "\\end{DoxyVerb}\n";
262 case DocVerbatim::HtmlOnly:
263 case DocVerbatim::XmlOnly:
264 case DocVerbatim::ManOnly:
265 case DocVerbatim::RtfOnly:
266 case DocVerbatim::DocbookOnly:
269 case DocVerbatim::LatexOnly:
272 case DocVerbatim::Dot:
274 static int dotindex = 1;
275 QCString fileName(4096);
277 fileName.sprintf("%s%d%s",
278 (Config_getString("LATEX_OUTPUT")+"/inline_dotgraph_").data(),
282 QFile file(fileName);
283 if (!file.open(IO_WriteOnly))
285 err("Could not open file %s for writing\n",fileName.data());
287 file.writeBlock( s->text(), s->text().length() );
290 m_t << "\\begin{center}\n";
291 startDotFile(fileName,"","",FALSE);
293 m_t << "\\end{center}\n";
295 if (Config_getBool("DOT_CLEANUP")) file.remove();
298 case DocVerbatim::Msc:
300 static int mscindex = 1;
301 QCString baseName(4096);
303 baseName.sprintf("%s%d",
304 (Config_getString("LATEX_OUTPUT")+"/inline_mscgraph_").data(),
307 QFile file(baseName+".msc");
308 if (!file.open(IO_WriteOnly))
310 err("Could not open file %s.msc for writing\n",baseName.data());
312 QCString text = "msc {";
315 file.writeBlock( text, text.length() );
318 m_t << "\\begin{center}\n";
319 writeMscFile(baseName);
320 m_t << "\\end{center}\n";
322 if (Config_getBool("DOT_CLEANUP")) file.remove();
325 case DocVerbatim::PlantUML:
327 QCString latexOutput = Config_getString("LATEX_OUTPUT");
328 QCString baseName = writePlantUMLSource(latexOutput,s->exampleFile(),s->text());
330 m_t << "\\begin{center}\n";
331 writePlantUMLFile(baseName);
332 m_t << "\\end{center}\n";
338 void LatexDocVisitor::visit(DocAnchor *anc)
341 m_t << "\\label{" << stripPath(anc->file()) << "_" << anc->anchor() << "}%" << endl;
342 if (!anc->file().isEmpty() && Config_getBool("PDF_HYPERLINKS"))
344 m_t << "\\hypertarget{" << stripPath(anc->file()) << "_" << anc->anchor()
349 void LatexDocVisitor::visit(DocInclude *inc)
352 SrcLangExt langExt = getLanguageFromFileName(inc->extension());
355 case DocInclude::IncWithLines:
357 m_t << "\n\\begin{DoxyCodeInclude}\n";
358 QFileInfo cfi( inc->file() );
359 FileDef fd( cfi.dirPath().utf8(), cfi.fileName().utf8() );
360 Doxygen::parserManager->getParser(inc->extension())
361 ->parseCode(m_ci,inc->context(),
365 inc->exampleFile(), &fd);
366 m_t << "\\end{DoxyCodeInclude}" << endl;
369 case DocInclude::Include:
370 m_t << "\n\\begin{DoxyCodeInclude}\n";
371 Doxygen::parserManager->getParser(inc->extension())
372 ->parseCode(m_ci,inc->context(),
373 inc->text(),langExt,inc->isExample(),
375 m_t << "\\end{DoxyCodeInclude}\n";
377 case DocInclude::DontInclude:
379 case DocInclude::HtmlInclude:
381 case DocInclude::LatexInclude:
384 case DocInclude::VerbInclude:
385 m_t << "\n\\begin{DoxyVerbInclude}\n";
387 m_t << "\\end{DoxyVerbInclude}\n";
389 case DocInclude::Snippet:
391 m_t << "\n\\begin{DoxyCodeInclude}\n";
392 Doxygen::parserManager->getParser(inc->extension())
395 extractBlock(inc->text(),inc->blockId()),
400 m_t << "\\end{DoxyCodeInclude}" << endl;
406 void LatexDocVisitor::visit(DocIncOperator *op)
408 //printf("DocIncOperator: type=%d first=%d, last=%d text=`%s'\n",
409 // op->type(),op->isFirst(),op->isLast(),op->text().data());
412 if (!m_hide) m_t << "\n\\begin{DoxyCodeInclude}\n";
416 SrcLangExt langExt = getLanguageFromFileName(m_langExt);
417 if (op->type()!=DocIncOperator::Skip)
422 Doxygen::parserManager->getParser(m_langExt)
423 ->parseCode(m_ci,op->context(),op->text(),langExt,
424 op->isExample(),op->exampleFile());
432 if (!m_hide) m_t << "\n\\end{DoxyCodeInclude}\n";
436 if (!m_hide) m_t << endl;
440 void LatexDocVisitor::visit(DocFormula *f)
446 void LatexDocVisitor::visit(DocIndexEntry *i)
449 m_t << "\\index{" << escapeLabelName(i->entry()) << "@{";
450 escapeMakeIndexChars(i->entry());
454 void LatexDocVisitor::visit(DocSimpleSectSep *)
458 void LatexDocVisitor::visit(DocCite *cite)
461 if (!cite->file().isEmpty())
463 //startLink(cite->ref(),cite->file(),cite->anchor());
464 QCString anchor = cite->anchor();
465 anchor = anchor.mid(CiteConsts::anchorPrefix.length()); // strip prefix
466 m_t << "\\cite{" << anchor << "}";
470 m_t << "{\\bfseries [";
471 filter(cite->text());
476 //--------------------------------------
477 // visitor functions for compound nodes
478 //--------------------------------------
480 void LatexDocVisitor::visitPre(DocAutoList *l)
485 m_t << "\n\\begin{DoxyEnumerate}";
489 m_t << "\n\\begin{DoxyItemize}";
493 void LatexDocVisitor::visitPost(DocAutoList *l)
498 m_t << "\n\\end{DoxyEnumerate}";
502 m_t << "\n\\end{DoxyItemize}";
506 void LatexDocVisitor::visitPre(DocAutoListItem *)
512 void LatexDocVisitor::visitPost(DocAutoListItem *)
516 void LatexDocVisitor::visitPre(DocPara *)
520 void LatexDocVisitor::visitPost(DocPara *p)
523 if (!p->isLast() && // omit <p> for last paragraph
524 !(p->parent() && // and for parameter sections
525 p->parent()->kind()==DocNode::Kind_ParamSect
527 ) m_t << endl << endl;
530 void LatexDocVisitor::visitPre(DocRoot *)
534 void LatexDocVisitor::visitPost(DocRoot *)
538 void LatexDocVisitor::visitPre(DocSimpleSect *s)
543 case DocSimpleSect::See:
544 m_t << "\\begin{DoxySeeAlso}{";
545 filter(theTranslator->trSeeAlso());
547 case DocSimpleSect::Return:
548 m_t << "\\begin{DoxyReturn}{";
549 filter(theTranslator->trReturns());
551 case DocSimpleSect::Author:
552 m_t << "\\begin{DoxyAuthor}{";
553 filter(theTranslator->trAuthor(TRUE,TRUE));
555 case DocSimpleSect::Authors:
556 m_t << "\\begin{DoxyAuthor}{";
557 filter(theTranslator->trAuthor(TRUE,FALSE));
559 case DocSimpleSect::Version:
560 m_t << "\\begin{DoxyVersion}{";
561 filter(theTranslator->trVersion());
563 case DocSimpleSect::Since:
564 m_t << "\\begin{DoxySince}{";
565 filter(theTranslator->trSince());
567 case DocSimpleSect::Date:
568 m_t << "\\begin{DoxyDate}{";
569 filter(theTranslator->trDate());
571 case DocSimpleSect::Note:
572 m_t << "\\begin{DoxyNote}{";
573 filter(theTranslator->trNote());
575 case DocSimpleSect::Warning:
576 m_t << "\\begin{DoxyWarning}{";
577 filter(theTranslator->trWarning());
579 case DocSimpleSect::Pre:
580 m_t << "\\begin{DoxyPrecond}{";
581 filter(theTranslator->trPrecondition());
583 case DocSimpleSect::Post:
584 m_t << "\\begin{DoxyPostcond}{";
585 filter(theTranslator->trPostcondition());
587 case DocSimpleSect::Copyright:
588 m_t << "\\begin{DoxyCopyright}{";
589 filter(theTranslator->trCopyright());
591 case DocSimpleSect::Invar:
592 m_t << "\\begin{DoxyInvariant}{";
593 filter(theTranslator->trInvariant());
595 case DocSimpleSect::Remark:
596 m_t << "\\begin{DoxyRemark}{";
597 filter(theTranslator->trRemarks());
599 case DocSimpleSect::Attention:
600 m_t << "\\begin{DoxyAttention}{";
601 filter(theTranslator->trAttention());
603 case DocSimpleSect::User:
604 m_t << "\\begin{DoxyParagraph}{";
606 case DocSimpleSect::Rcs:
607 m_t << "\\begin{DoxyParagraph}{";
609 case DocSimpleSect::Unknown: break;
612 // special case 1: user defined title
613 if (s->type()!=DocSimpleSect::User && s->type()!=DocSimpleSect::Rcs)
623 void LatexDocVisitor::visitPost(DocSimpleSect *s)
628 case DocSimpleSect::See:
629 m_t << "\n\\end{DoxySeeAlso}\n";
631 case DocSimpleSect::Return:
632 m_t << "\n\\end{DoxyReturn}\n";
634 case DocSimpleSect::Author:
635 m_t << "\n\\end{DoxyAuthor}\n";
637 case DocSimpleSect::Authors:
638 m_t << "\n\\end{DoxyAuthor}\n";
640 case DocSimpleSect::Version:
641 m_t << "\n\\end{DoxyVersion}\n";
643 case DocSimpleSect::Since:
644 m_t << "\n\\end{DoxySince}\n";
646 case DocSimpleSect::Date:
647 m_t << "\n\\end{DoxyDate}\n";
649 case DocSimpleSect::Note:
650 m_t << "\n\\end{DoxyNote}\n";
652 case DocSimpleSect::Warning:
653 m_t << "\n\\end{DoxyWarning}\n";
655 case DocSimpleSect::Pre:
656 m_t << "\n\\end{DoxyPrecond}\n";
658 case DocSimpleSect::Post:
659 m_t << "\n\\end{DoxyPostcond}\n";
661 case DocSimpleSect::Copyright:
662 m_t << "\n\\end{DoxyCopyright}\n";
664 case DocSimpleSect::Invar:
665 m_t << "\n\\end{DoxyInvariant}\n";
667 case DocSimpleSect::Remark:
668 m_t << "\n\\end{DoxyRemark}\n";
670 case DocSimpleSect::Attention:
671 m_t << "\n\\end{DoxyAttention}\n";
673 case DocSimpleSect::User:
674 m_t << "\n\\end{DoxyParagraph}\n";
676 case DocSimpleSect::Rcs:
677 m_t << "\n\\end{DoxyParagraph}\n";
684 void LatexDocVisitor::visitPre(DocTitle *)
688 void LatexDocVisitor::visitPost(DocTitle *)
695 void LatexDocVisitor::visitPre(DocSimpleList *)
698 m_t << "\\begin{DoxyItemize}" << endl;
701 void LatexDocVisitor::visitPost(DocSimpleList *)
704 m_t << "\\end{DoxyItemize}" << endl;
707 void LatexDocVisitor::visitPre(DocSimpleListItem *)
713 void LatexDocVisitor::visitPost(DocSimpleListItem *)
717 void LatexDocVisitor::visitPre(DocSection *s)
720 if (Config_getBool("PDF_HYPERLINKS"))
722 m_t << "\\hypertarget{" << stripPath(s->file()) << "_" << s->anchor() << "}{}";
724 m_t << "\\" << getSectionName(s->level()) << "{";
725 filter(convertCharEntitiesToUTF8(s->title().data()));
726 m_t << "}\\label{" << stripPath(s->file()) << "_" << s->anchor() << "}" << endl;
729 void LatexDocVisitor::visitPost(DocSection *)
733 void LatexDocVisitor::visitPre(DocHtmlList *s)
736 if (s->type()==DocHtmlList::Ordered)
737 m_t << "\n\\begin{DoxyEnumerate}";
739 m_t << "\n\\begin{DoxyItemize}";
742 void LatexDocVisitor::visitPost(DocHtmlList *s)
745 if (s->type()==DocHtmlList::Ordered)
746 m_t << "\n\\end{DoxyEnumerate}";
748 m_t << "\n\\end{DoxyItemize}";
751 void LatexDocVisitor::visitPre(DocHtmlListItem *)
757 void LatexDocVisitor::visitPost(DocHtmlListItem *)
761 //void LatexDocVisitor::visitPre(DocHtmlPre *)
763 // m_t << "\\small\\begin{alltt}";
767 //void LatexDocVisitor::visitPost(DocHtmlPre *)
769 // m_insidePre=FALSE;
770 // m_t << "\\end{alltt}\\normalsize " << endl;
773 void LatexDocVisitor::visitPre(DocHtmlDescList *dl)
776 QCString val = dl->attribs().find("class");
779 m_t << "\n\\begin{DoxyRefList}";
783 m_t << "\n\\begin{DoxyDescription}";
787 void LatexDocVisitor::visitPost(DocHtmlDescList *dl)
790 QCString val = dl->attribs().find("class");
793 m_t << "\n\\end{DoxyRefList}";
797 m_t << "\n\\end{DoxyDescription}";
801 void LatexDocVisitor::visitPre(DocHtmlDescTitle *)
808 void LatexDocVisitor::visitPost(DocHtmlDescTitle *)
815 void LatexDocVisitor::visitPre(DocHtmlDescData *)
819 void LatexDocVisitor::visitPost(DocHtmlDescData *)
823 static const char *getTableName(const DocNode *n)
826 while (n && !isNested)
828 isNested = n->kind()==DocNode::Kind_HtmlTable;
831 return isNested ? "TabularNC" : "TabularC";
834 void LatexDocVisitor::visitPre(DocHtmlTable *t)
841 m_t << "\\begin{table}[h]";
843 m_t << "\\begin{" << getTableName(t->parent()) << "}{" << t->numColumns() << "}\n";
844 m_numCols = t->numColumns();
848 void LatexDocVisitor::visitPost(DocHtmlTable *t)
854 m_t << "\\end{table}\n";
858 m_t << "\\end{" << getTableName(t->parent()) << "}\n";
862 void LatexDocVisitor::visitPre(DocHtmlCaption *c)
865 m_t << "\\end{" << getTableName(c->parent()) << "}\n\\centering\n\\caption{";
868 void LatexDocVisitor::visitPost(DocHtmlCaption *)
874 void LatexDocVisitor::visitPre(DocHtmlRow *r)
877 if (r->isHeading()) m_t << "\\rowcolor{lightgray}";
880 void LatexDocVisitor::visitPost(DocHtmlRow *row)
884 int c=m_currentColumn;
885 while (c<=m_numCols) // end of row while inside a row span?
888 for (i=0;i<m_rowSpans.count();i++)
890 ActiveRowSpan *span = m_rowSpans.at(i);
891 //printf(" founc row span: column=%d rs=%d cs=%d rowIdx=%d cell->rowIdx=%d\n",
892 // span->column, span->rowSpan,span->colSpan,row->rowIndex(),span->cell->rowIndex());
893 if (span->rowSpan>0 && span->column==c && // we are at a cell in a row span
894 row->rowIndex()>span->cell->rowIndex() // but not the row that started the span
898 if (span->colSpan>1) // row span is also part of a column span
900 m_t << "\\multicolumn{" << span->colSpan << "}{";
901 m_t << "p{(\\linewidth-\\tabcolsep*"
902 << m_numCols << "-\\arrayrulewidth*"
903 << row->visibleCells() << ")*"
904 << span->colSpan <<"/"<< m_numCols << "}|}{}";
906 else // solitary row span
908 m_t << "\\multicolumn{1}{c|}{}";
919 for (i=0;i<m_rowSpans.count();i++)
921 ActiveRowSpan *span = m_rowSpans.at(i);
922 if (span->rowSpan>0) span->rowSpan--;
923 if (span->rowSpan<=0)
927 else if (span->column>col)
929 m_t << "\\cline{" << col << "-" << (span->column-1) << "}";
930 col = span->column+span->colSpan;
934 col = span->column+span->colSpan;
938 if (col <= m_numCols)
940 m_t << "\\cline{" << col << "-" << m_numCols << "}";
946 void LatexDocVisitor::visitPre(DocHtmlCell *c)
951 if (c->parent() && c->parent()->kind()==DocNode::Kind_HtmlRow)
953 row = (DocHtmlRow*)c->parent();
958 //Skip columns that span from above.
960 for (i=0;i<m_rowSpans.count();i++)
962 ActiveRowSpan *span = m_rowSpans.at(i);
963 if (span->rowSpan>0 && span->column==m_currentColumn)
965 if (row && span->colSpan>1)
967 m_t << "\\multicolumn{" << span->colSpan << "}{";
968 if (m_currentColumn /*c->columnIndex()*/==1) // add extra | for first column
972 m_t << "p{(\\linewidth-\\tabcolsep*"
973 << m_numCols << "-\\arrayrulewidth*"
974 << row->visibleCells() << ")*"
975 << span->colSpan <<"/"<< m_numCols << "}|}{}";
976 m_currentColumn+=span->colSpan;
987 QMap<int, int>::Iterator it = m_rowspanIndices.find(m_currentColumn);
988 if (it!=m_rowspanIndices.end() && it.data()>0)
996 int cs = c->colSpan();
1000 m_t << "\\multicolumn{" << cs << "}{";
1001 if (c->columnIndex()==1) // add extra | for first column
1005 m_t << "p{(\\linewidth-\\tabcolsep*"
1006 << m_numCols << "-\\arrayrulewidth*"
1007 << row->visibleCells() << ")*"
1008 << cs <<"/"<< m_numCols << "}|}{";
1009 if (c->isHeading()) m_t << "\\cellcolor{lightgray}";
1011 int rs = c->rowSpan();
1015 //m_rowspanIndices[m_currentColumn] = rs;
1016 m_rowSpans.append(new ActiveRowSpan(c,rs,cs,m_currentColumn));
1017 m_t << "\\multirow{" << rs << "}{\\linewidth}{";
1019 int a = c->alignment();
1020 if (a==DocHtmlCell::Center)
1022 m_t << "\\PBS\\centering ";
1024 else if (a==DocHtmlCell::Right)
1026 m_t << "\\PBS\\raggedleft ";
1034 m_currentColumn+=cs-1;
1038 void LatexDocVisitor::visitPost(DocHtmlCell *c)
1047 m_inRowspan = FALSE;
1052 m_inColspan = FALSE;
1055 if (!c->isLast()) m_t << "&";
1058 void LatexDocVisitor::visitPre(DocInternal *)
1061 //m_t << "\\begin{DoxyInternal}{";
1062 //filter(theTranslator->trForInternalUseOnly());
1066 void LatexDocVisitor::visitPost(DocInternal *)
1069 //m_t << "\\end{DoxyInternal}" << endl;
1072 void LatexDocVisitor::visitPre(DocHRef *href)
1075 if (Config_getBool("PDF_HYPERLINKS"))
1084 void LatexDocVisitor::visitPost(DocHRef *)
1090 void LatexDocVisitor::visitPre(DocHtmlHeader *header)
1093 m_t << "\\" << getSectionName(header->level()) << "*{";
1096 void LatexDocVisitor::visitPost(DocHtmlHeader *)
1102 void LatexDocVisitor::visitPre(DocImage *img)
1104 if (img->type()==DocImage::Latex)
1107 if (img->hasCaption())
1109 m_t << "\n\\begin{DoxyImage}\n";
1113 m_t << "\n\\begin{DoxyImageNoCaption}\n"
1116 QCString gfxName = img->name();
1117 if (gfxName.right(4)==".eps" || gfxName.right(4)==".pdf")
1119 gfxName=gfxName.left(gfxName.length()-4);
1121 m_t << "\\includegraphics";
1122 if (!img->width().isEmpty())
1124 m_t << "[width=" << img->width() << "]";
1126 else if (!img->height().isEmpty())
1128 m_t << "[height=" << img->height() << "]";
1130 m_t << "{" << gfxName << "}";
1131 if (img->hasCaption())
1133 m_t << "\n\\caption{";
1136 else // other format -> skip
1143 void LatexDocVisitor::visitPost(DocImage *img)
1145 if (img->type()==DocImage::Latex)
1148 m_t << "}\n"; // end mbox or caption
1149 if (img->hasCaption())
1151 m_t << "\\end{DoxyImage}\n";
1154 m_t << "\\end{DoxyImageNoCaption}\n";
1157 else // other format
1163 void LatexDocVisitor::visitPre(DocDotFile *df)
1166 startDotFile(df->file(),df->width(),df->height(),df->hasCaption());
1169 void LatexDocVisitor::visitPost(DocDotFile *df)
1172 endDotFile(df->hasCaption());
1174 void LatexDocVisitor::visitPre(DocMscFile *df)
1177 startMscFile(df->file(),df->width(),df->height(),df->hasCaption());
1180 void LatexDocVisitor::visitPost(DocMscFile *df)
1183 endMscFile(df->hasCaption());
1186 void LatexDocVisitor::visitPre(DocDiaFile *df)
1189 startDiaFile(df->file(),df->width(),df->height(),df->hasCaption());
1192 void LatexDocVisitor::visitPost(DocDiaFile *df)
1195 endDiaFile(df->hasCaption());
1197 void LatexDocVisitor::visitPre(DocLink *lnk)
1200 startLink(lnk->ref(),lnk->file(),lnk->anchor());
1203 void LatexDocVisitor::visitPost(DocLink *lnk)
1206 endLink(lnk->ref(),lnk->file(),lnk->anchor());
1209 void LatexDocVisitor::visitPre(DocRef *ref)
1212 // when ref->isSubPage()==TRUE we use ref->file() for HTML and
1213 // ref->anchor() for LaTeX/RTF
1214 if (ref->isSubPage())
1216 startLink(ref->ref(),0,ref->anchor());
1220 if (!ref->file().isEmpty()) startLink(ref->ref(),ref->file(),ref->anchor());
1222 if (!ref->hasLinkText()) filter(ref->targetTitle());
1225 void LatexDocVisitor::visitPost(DocRef *ref)
1228 if (ref->isSubPage())
1230 endLink(ref->ref(),0,ref->anchor());
1234 if (!ref->file().isEmpty()) endLink(ref->ref(),ref->file(),ref->anchor());
1238 void LatexDocVisitor::visitPre(DocSecRefItem *ref)
1241 m_t << "\\item \\contentsline{section}{";
1242 static bool pdfHyperlinks = Config_getBool("PDF_HYPERLINKS");
1245 m_t << "\\hyperlink{" << ref->file() << "_" << ref->anchor() << "}{" ;
1249 void LatexDocVisitor::visitPost(DocSecRefItem *ref)
1252 static bool pdfHyperlinks = Config_getBool("PDF_HYPERLINKS");
1257 m_t << "}{\\ref{" << ref->file() << "_" << ref->anchor() << "}}{}" << endl;
1260 void LatexDocVisitor::visitPre(DocSecRefList *)
1263 m_t << "\\footnotesize" << endl;
1264 m_t << "\\begin{multicols}{2}" << endl;
1265 m_t << "\\begin{DoxyCompactList}" << endl;
1268 void LatexDocVisitor::visitPost(DocSecRefList *)
1271 m_t << "\\end{DoxyCompactList}" << endl;
1272 m_t << "\\end{multicols}" << endl;
1273 m_t << "\\normalsize" << endl;
1276 void LatexDocVisitor::visitPre(DocParamSect *s)
1279 bool hasInOutSpecs = s->hasInOutSpecifier();
1280 bool hasTypeSpecs = s->hasTypeSpecifier();
1283 case DocParamSect::Param:
1284 m_t << "\n\\begin{DoxyParams}";
1285 if (hasInOutSpecs && hasTypeSpecs) m_t << "[2]"; // 2 extra cols
1286 else if (hasInOutSpecs || hasTypeSpecs) m_t << "[1]"; // 1 extra col
1288 filter(theTranslator->trParameters());
1290 case DocParamSect::RetVal:
1291 m_t << "\n\\begin{DoxyRetVals}{";
1292 filter(theTranslator->trReturnValues());
1294 case DocParamSect::Exception:
1295 m_t << "\n\\begin{DoxyExceptions}{";
1296 filter(theTranslator->trExceptions());
1298 case DocParamSect::TemplateParam:
1300 filter(theTranslator->trTemplateParam()); break;
1302 m_t << "\n\\begin{DoxyTemplParams}{";
1303 filter("Template Parameters");
1311 void LatexDocVisitor::visitPost(DocParamSect *s)
1316 case DocParamSect::Param:
1317 m_t << "\\end{DoxyParams}\n";
1319 case DocParamSect::RetVal:
1320 m_t << "\\end{DoxyRetVals}\n";
1322 case DocParamSect::Exception:
1323 m_t << "\\end{DoxyExceptions}\n";
1325 case DocParamSect::TemplateParam:
1326 m_t << "\\end{DoxyTemplParams}\n";
1333 void LatexDocVisitor::visitPre(DocParamList *pl)
1336 DocParamSect::Type parentType = DocParamSect::Unknown;
1337 DocParamSect *sect = 0;
1338 if (pl->parent() && pl->parent()->kind()==DocNode::Kind_ParamSect)
1340 parentType = ((DocParamSect*)pl->parent())->type();
1341 sect=(DocParamSect*)pl->parent();
1343 bool useTable = parentType==DocParamSect::Param ||
1344 parentType==DocParamSect::RetVal ||
1345 parentType==DocParamSect::Exception ||
1346 parentType==DocParamSect::TemplateParam;
1351 if (sect && sect->hasInOutSpecifier())
1353 if (pl->direction()!=DocParamSect::Unspecified)
1355 m_t << "\\mbox{\\tt ";
1356 if (pl->direction()==DocParamSect::In)
1360 else if (pl->direction()==DocParamSect::Out)
1364 else if (pl->direction()==DocParamSect::InOut)
1370 if (useTable) m_t << " & ";
1372 if (sect && sect->hasTypeSpecifier())
1374 QListIterator<DocNode> li(pl->paramTypes());
1377 for (li.toFirst();(type=li.current());++li)
1379 if (!first) m_t << " | "; else first=FALSE;
1380 if (type->kind()==DocNode::Kind_Word)
1382 visit((DocWord*)type);
1384 else if (type->kind()==DocNode::Kind_LinkedWord)
1386 visit((DocLinkedWord*)type);
1389 if (useTable) m_t << " & ";
1392 //QStrListIterator li(pl->parameters());
1394 QListIterator<DocNode> li(pl->parameters());
1397 for (li.toFirst();(param=li.current());++li)
1399 if (!first) m_t << ","; else first=FALSE;
1401 if (param->kind()==DocNode::Kind_Word)
1403 visit((DocWord*)param);
1405 else if (param->kind()==DocNode::Kind_LinkedWord)
1407 visit((DocLinkedWord*)param);
1422 void LatexDocVisitor::visitPost(DocParamList *pl)
1425 DocParamSect::Type parentType = DocParamSect::Unknown;
1426 if (pl->parent() && pl->parent()->kind()==DocNode::Kind_ParamSect)
1428 parentType = ((DocParamSect*)pl->parent())->type();
1430 bool useTable = parentType==DocParamSect::Param ||
1431 parentType==DocParamSect::RetVal ||
1432 parentType==DocParamSect::Exception ||
1433 parentType==DocParamSect::TemplateParam;
1436 m_t << "\\\\" << endl
1437 << "\\hline" << endl;
1441 void LatexDocVisitor::visitPre(DocXRefItem *x)
1444 if (x->title().isEmpty()) return;
1445 m_t << "\\begin{DoxyRefDesc}{";
1448 bool anonymousEnum = x->file()=="@";
1450 if (Config_getBool("PDF_HYPERLINKS") && !anonymousEnum)
1452 m_t << "\\hyperlink{" << stripPath(x->file()) << "_" << x->anchor() << "}{";
1464 void LatexDocVisitor::visitPost(DocXRefItem *x)
1467 if (x->title().isEmpty()) return;
1468 m_t << "\\end{DoxyRefDesc}" << endl;
1471 void LatexDocVisitor::visitPre(DocInternalRef *ref)
1474 startLink(0,ref->file(),ref->anchor());
1477 void LatexDocVisitor::visitPost(DocInternalRef *ref)
1480 endLink(0,ref->file(),ref->anchor());
1483 void LatexDocVisitor::visitPre(DocCopy *)
1487 void LatexDocVisitor::visitPost(DocCopy *)
1491 void LatexDocVisitor::visitPre(DocText *)
1495 void LatexDocVisitor::visitPost(DocText *)
1499 void LatexDocVisitor::visitPre(DocHtmlBlockQuote *)
1502 m_t << "\\begin{quote}" << endl;
1505 void LatexDocVisitor::visitPost(DocHtmlBlockQuote *)
1508 m_t << "\\end{quote}" << endl;
1511 void LatexDocVisitor::visitPre(DocVhdlFlow *)
1516 void LatexDocVisitor::visitPost(DocVhdlFlow *)
1521 void LatexDocVisitor::visitPre(DocParBlock *)
1526 void LatexDocVisitor::visitPost(DocParBlock *)
1531 void LatexDocVisitor::filter(const char *str)
1533 filterLatexString(m_t,str,m_insideTabbing,m_insidePre,m_insideItem);
1536 void LatexDocVisitor::startLink(const QCString &ref,const QCString &file,const QCString &anchor)
1538 if (ref.isEmpty() && Config_getBool("PDF_HYPERLINKS")) // internal PDF link
1540 if (ref.isEmpty()) {
1541 m_t << "\\hyperlink{";
1542 if (!file.isEmpty()) m_t << stripPath(file);
1543 if (!file.isEmpty() && !anchor.isEmpty()) m_t << "_";
1544 if (!anchor.isEmpty()) m_t << anchor;
1551 if ((dest=Doxygen::tagDestinationDict[ref])) m_t << *dest << "/";
1552 if (!file.isEmpty()) m_t << file << Doxygen::htmlFileExtension;
1553 if (!anchor.isEmpty()) m_t << "#" << anchor;
1557 else if (ref.isEmpty()) // internal non-PDF link
1559 m_t << "\\doxyref{";
1561 else // external link
1567 void LatexDocVisitor::endLink(const QCString &ref,const QCString &file,const QCString &anchor)
1570 if (ref.isEmpty() && !Config_getBool("PDF_HYPERLINKS"))
1573 filter(theTranslator->trPageAbbreviation());
1574 m_t << "}{" << file;
1575 if (!file.isEmpty() && !anchor.isEmpty()) m_t << "_";
1576 m_t << anchor << "}";
1580 void LatexDocVisitor::pushEnabled()
1582 m_enabled.push(new bool(m_hide));
1585 void LatexDocVisitor::popEnabled()
1587 bool *v=m_enabled.pop();
1593 void LatexDocVisitor::startDotFile(const QCString &fileName,
1594 const QCString &width,
1595 const QCString &height,
1599 QCString baseName=fileName;
1601 if ((i=baseName.findRev('/'))!=-1)
1603 baseName=baseName.right(baseName.length()-i-1);
1605 if ((i=baseName.find('.'))!=-1)
1607 baseName=baseName.left(i);
1609 baseName.prepend("dot_");
1610 QCString outDir = Config_getString("LATEX_OUTPUT");
1611 QCString name = fileName;
1612 writeDotGraphFromFile(name,outDir,baseName,GOF_EPS);
1615 m_t << "\n\\begin{DoxyImage}\n";
1619 m_t << "\n\\begin{DoxyImageNoCaption}\n"
1622 m_t << "\\includegraphics";
1623 if (!width.isEmpty())
1625 m_t << "[width=" << width << "]";
1627 else if (!height.isEmpty())
1629 m_t << "[height=" << height << "]";
1633 m_t << "[width=\\textwidth,height=\\textheight/2,keepaspectratio=true]";
1635 m_t << "{" << baseName;
1636 //if (Config_getBool("USE_PDFLATEX"))
1648 m_t << "\n\\caption{";
1652 void LatexDocVisitor::endDotFile(bool hasCaption)
1655 m_t << "}\n"; // end caption or mbox
1658 m_t << "\\end{DoxyImage}\n";
1662 m_t << "\\end{DoxyImageNoCaption}\n";
1666 void LatexDocVisitor::startMscFile(const QCString &fileName,
1667 const QCString &width,
1668 const QCString &height,
1672 QCString baseName=fileName;
1674 if ((i=baseName.findRev('/'))!=-1)
1676 baseName=baseName.right(baseName.length()-i-1);
1678 if ((i=baseName.find('.'))!=-1)
1680 baseName=baseName.left(i);
1682 baseName.prepend("msc_");
1684 QCString outDir = Config_getString("LATEX_OUTPUT");
1685 writeMscGraphFromFile(fileName,outDir,baseName,MSC_EPS);
1688 m_t << "\n\\begin{DoxyImage}\n";
1692 m_t << "\n\\begin{DoxyImageNoCaption}\n"
1695 m_t << "\\includegraphics";
1696 if (!width.isEmpty())
1698 m_t << "[width=" << width << "]";
1700 else if (!height.isEmpty())
1702 m_t << "[height=" << height << "]";
1706 m_t << "[width=\\textwidth,height=\\textheight/2,keepaspectratio=true]";
1708 m_t << "{" << baseName;
1709 //if (Config_getBool("USE_PDFLATEX"))
1721 m_t << "\n\\caption{";
1725 void LatexDocVisitor::endMscFile(bool hasCaption)
1728 m_t << "}\n"; // end caption or mbox
1731 m_t << "\\end{DoxyImage}\n";
1735 m_t << "\\end{DoxyImageNoCaption}\n";
1740 void LatexDocVisitor::writeMscFile(const QCString &baseName)
1742 QCString shortName = baseName;
1744 if ((i=shortName.findRev('/'))!=-1)
1746 shortName=shortName.right(shortName.length()-i-1);
1748 QCString outDir = Config_getString("LATEX_OUTPUT");
1749 writeMscGraphFromFile(baseName+".msc",outDir,shortName,MSC_EPS);
1750 m_t << "\n\\begin{DoxyImageNoCaption}"
1751 " \\mbox{\\includegraphics";
1752 m_t << "{" << shortName << "}";
1753 m_t << "}\n"; // end mbox
1754 m_t << "\\end{DoxyImageNoCaption}\n";
1758 void LatexDocVisitor::startDiaFile(const QCString &fileName,
1759 const QCString &width,
1760 const QCString &height,
1764 QCString baseName=fileName;
1766 if ((i=baseName.findRev('/'))!=-1)
1768 baseName=baseName.right(baseName.length()-i-1);
1770 if ((i=baseName.find('.'))!=-1)
1772 baseName=baseName.left(i);
1774 baseName.prepend("dia_");
1776 QCString outDir = Config_getString("LATEX_OUTPUT");
1777 writeDiaGraphFromFile(fileName,outDir,baseName,DIA_EPS);
1780 m_t << "\n\\begin{DoxyImage}\n";
1784 m_t << "\n\\begin{DoxyImageNoCaption}\n"
1787 m_t << "\\includegraphics";
1788 if (!width.isEmpty())
1790 m_t << "[width=" << width << "]";
1792 else if (!height.isEmpty())
1794 m_t << "[height=" << height << "]";
1798 m_t << "[width=\\textwidth,height=\\textheight/2,keepaspectratio=true]";
1800 m_t << "{" << baseName;
1801 //if (Config_getBool("USE_PDFLATEX"))
1813 m_t << "\n\\caption{";
1817 void LatexDocVisitor::endDiaFile(bool hasCaption)
1820 m_t << "}\n"; // end caption or mbox
1823 m_t << "\\end{DoxyImage}\n";
1827 m_t << "\\end{DoxyImageNoCaption}\n";
1832 void LatexDocVisitor::writeDiaFile(const QCString &baseName)
1834 QCString shortName = baseName;
1836 if ((i=shortName.findRev('/'))!=-1)
1838 shortName=shortName.right(shortName.length()-i-1);
1840 QCString outDir = Config_getString("LATEX_OUTPUT");
1841 writeDiaGraphFromFile(baseName+".dia",outDir,shortName,DIA_EPS);
1842 m_t << "\n\\begin{DoxyImageNoCaption}"
1843 " \\mbox{\\includegraphics";
1844 m_t << "{" << shortName << "}";
1845 m_t << "}\n"; // end mbox
1846 m_t << "\\end{DoxyImageNoCaption}\n";
1849 void LatexDocVisitor::writePlantUMLFile(const QCString &baseName)
1851 QCString shortName = baseName;
1853 if ((i=shortName.findRev('/'))!=-1)
1855 shortName=shortName.right(shortName.length()-i-1);
1857 QCString outDir = Config_getString("LATEX_OUTPUT");
1858 generatePlantUMLOutput(baseName,outDir,PUML_EPS);
1859 m_t << "\n\\begin{DoxyImageNoCaption}"
1860 " \\mbox{\\includegraphics";
1861 m_t << "{" << shortName << "}";
1862 m_t << "}\n"; // end mbox
1863 m_t << "\\end{DoxyImageNoCaption}\n";