summaryrefslogtreecommitdiffstats
path: root/src/latexgen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/latexgen.cpp')
-rw-r--r--src/latexgen.cpp157
1 files changed, 82 insertions, 75 deletions
diff --git a/src/latexgen.cpp b/src/latexgen.cpp
index b70f82a..3f4435f 100644
--- a/src/latexgen.cpp
+++ b/src/latexgen.cpp
@@ -44,18 +44,14 @@
#include "resourcemgr.h"
#include "portable.h"
-static bool DoxyCodeOpen = FALSE;
-static bool DoxyCodeLineOpen = FALSE;
-//-------------------------------
-
LatexCodeGenerator::LatexCodeGenerator(FTextStream &t,const QCString &relPath,const QCString &sourceFileName)
- : m_relPath(relPath), m_sourceFileName(sourceFileName), m_col(0)
+ : m_relPath(relPath), m_sourceFileName(sourceFileName)
{
m_prettyCode=Config_getBool(LATEX_SOURCE_CODE);
setTextStream(t);
}
-LatexCodeGenerator::LatexCodeGenerator() : m_streamSet(FALSE), m_col(0)
+LatexCodeGenerator::LatexCodeGenerator()
{
m_prettyCode=Config_getBool(LATEX_SOURCE_CODE);
}
@@ -85,8 +81,8 @@ void LatexCodeGenerator::codify(const char *str)
//char cs[5];
int spacesToNextTabStop;
int tabSize = Config_getInt(TAB_SIZE);
- static signed char *result = NULL;
- static int lresult = 0;
+ static THREAD_LOCAL signed char *result = NULL;
+ static THREAD_LOCAL int lresult = 0;
int i;
while ((c=*p))
{
@@ -108,7 +104,9 @@ void LatexCodeGenerator::codify(const char *str)
m_col+=spacesToNextTabStop;
p++;
break;
- case '\n': (usedTableLevels()>0 && !DoxyCodeOpen) ? m_t << "\\newline\n" : m_t << '\n'; m_col=0; p++;
+ case '\n': m_t << '\n';
+ m_col=0;
+ p++;
break;
default:
i=0;
@@ -149,14 +147,13 @@ void LatexCodeGenerator::codify(const char *str)
COPYCHAR();
}
result[i]=0; // add terminator
- //if (m_prettyCode)
- //{
- filterLatexString(m_t,(const char *)result,FALSE,TRUE);
- //}
- //else
- //{
- // t << result;
- //}
+ filterLatexString(m_t,(const char *)result,
+ false, // insideTabbing
+ true, // insidePre
+ false, // insideItem
+ m_usedTableLevel>0, // insideTable
+ false // keepSpaces
+ );
break;
}
}
@@ -192,10 +189,10 @@ void LatexCodeGenerator::writeLineNumber(const char *ref,const char *fileName,co
{
bool usePDFLatex = Config_getBool(USE_PDFLATEX);
bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
- if (!DoxyCodeLineOpen)
+ if (!m_doxyCodeLineOpen)
{
m_t << "\\DoxyCodeLine{";
- DoxyCodeLineOpen = TRUE;
+ m_doxyCodeLineOpen = TRUE;
}
if (m_prettyCode)
{
@@ -231,19 +228,19 @@ void LatexCodeGenerator::writeLineNumber(const char *ref,const char *fileName,co
void LatexCodeGenerator::startCodeLine(bool)
{
m_col=0;
- if (!DoxyCodeLineOpen)
+ if (!m_doxyCodeLineOpen)
{
m_t << "\\DoxyCodeLine{";
- DoxyCodeLineOpen = TRUE;
+ m_doxyCodeLineOpen = TRUE;
}
}
void LatexCodeGenerator::endCodeLine()
{
- if (DoxyCodeLineOpen)
+ if (m_doxyCodeLineOpen)
{
m_t << "}";
- DoxyCodeLineOpen = FALSE;
+ m_doxyCodeLineOpen = FALSE;
}
codify("\n");
}
@@ -258,11 +255,20 @@ void LatexCodeGenerator::endFontClass()
m_t << "}";
}
-void LatexCodeGenerator::setDoxyCodeOpen(bool val)
+void LatexCodeGenerator::startCodeFragment(const char *style)
+{
+ m_t << "\n\\begin{" << style << "}{" << m_usedTableLevel << "}\n";
+}
+
+void LatexCodeGenerator::endCodeFragment(const char *style)
{
- DoxyCodeOpen = val;
+ //endCodeLine checks is there is still an open code line, if so closes it.
+ endCodeLine();
+
+ m_t << "\\end{" << style << "}\n";
}
+
//-------------------------------
LatexGenerator::LatexGenerator() : OutputGenerator(Config_getString(LATEX_OUTPUT))
@@ -515,7 +521,6 @@ static void writeDefaultHeaderPart1(FTextStream &t)
// Load required packages
t << "% Packages required by doxygen\n"
"\\usepackage{fixltx2e}\n" // for \textsubscript
- "\\usepackage{calc}\n"
"\\usepackage{doxygen}\n";
const StringVector &extraLatexStyles = Config_getList(LATEX_EXTRA_STYLESHEET);
for (const auto &extraStyle : extraLatexStyles)
@@ -541,13 +546,10 @@ static void writeDefaultHeaderPart1(FTextStream &t)
t << "\\usepackage{graphicx}\n"
"\\usepackage[utf8]{inputenc}\n"
"\\usepackage{makeidx}\n"
- "\\usepackage{multicol}\n"
- "\\usepackage{multirow}\n"
"\\PassOptionsToPackage{warn}{textcomp}\n"
"\\usepackage{textcomp}\n"
"\\usepackage[nointegrals]{wasysym}\n"
- "\\usepackage[table]{xcolor}\n"
- "\\usepackage{ifpdf,ifxetex}\n"
+ "\\usepackage{ifxetex}\n"
"\n";
// Language support
@@ -571,8 +573,7 @@ static void writeDefaultHeaderPart1(FTextStream &t)
{
t << font;
}
- t << "\\usepackage{amssymb}\n"
- "\\usepackage{sectsty}\n"
+ t << "\\usepackage{sectsty}\n"
"\\allsectionsfont{%\n"
" \\fontseries{bc}\\selectfont%\n"
" \\color{darkgray}%\n"
@@ -650,23 +651,34 @@ static void writeDefaultHeaderPart1(FTextStream &t)
{
generatedBy = theTranslator->trGeneratedBy();
}
- filterLatexString(tg, generatedBy, FALSE,FALSE,FALSE);
+ filterLatexString(tg, generatedBy,
+ false, // insideTabbing
+ false, // insidePre
+ false, // insideItem
+ false, // insideTable
+ false // keepSpaces
+ );
t << "% Headers & footers\n"
"\\usepackage{fancyhdr}\n"
"\\pagestyle{fancyplain}\n"
- "\\fancyhead[LE]{\\fancyplain{}{\\bfseries\\thepage}}\n"
- "\\fancyhead[CE]{\\fancyplain{}{}}\n"
- "\\fancyhead[RE]{\\fancyplain{}{\\bfseries\\leftmark}}\n"
- "\\fancyhead[LO]{\\fancyplain{}{\\bfseries\\rightmark}}\n"
- "\\fancyhead[CO]{\\fancyplain{}{}}\n"
- "\\fancyhead[RO]{\\fancyplain{}{\\bfseries\\thepage}}\n"
- "\\fancyfoot[LE]{\\fancyplain{}{}}\n"
- "\\fancyfoot[CE]{\\fancyplain{}{}}\n"
- "\\fancyfoot[RE]{\\fancyplain{}{\\bfseries\\scriptsize " << genString << " Doxygen }}\n"
- "\\fancyfoot[LO]{\\fancyplain{}{\\bfseries\\scriptsize " << genString << " Doxygen }}\n"
- "\\fancyfoot[CO]{\\fancyplain{}{}}\n"
- "\\fancyfoot[RO]{\\fancyplain{}{}}\n"
- "\\renewcommand{\\footrulewidth}{0.4pt}\n";
+ "\\renewcommand{\\footrulewidth}{0.4pt}\n"
+ "%\n"
+ "\\fancypagestyle{fancyplain}{\n"
+ "\\fancyhf{}\n"
+ "\\fancyhead[LE, RO]{\\bfseries\\thepage}\n"
+ "\\fancyhead[LO]{\\bfseries\\rightmark}\n"
+ "\\fancyhead[RE]{\\bfseries\\leftmark}\n"
+ "\\fancyfoot[LO, RE]{\\bfseries\\scriptsize " << genString << " Doxygen }\n"
+ "}\n"
+ "%\n"
+ "\\fancypagestyle{plain}{\n"
+ "\\fancyhf{}\n"
+ "\\fancyfoot[LO, RE]{\\bfseries\\scriptsize " << genString << " Doxygen }\n"
+ "\\renewcommand{\\headrulewidth}{0pt}}\n"
+ "%\n"
+ "\\pagestyle{fancyplain}\n"
+ "%\n";
+
if (!Config_getBool(COMPACT_LATEX))
{
t << "\\renewcommand{\\chaptermark}[1]{%\n"
@@ -757,7 +769,8 @@ static void writeDefaultHeaderPart1(FTextStream &t)
// End of preamble, now comes the document contents
t << "%===== C O N T E N T S =====\n"
"\n"
- "\\begin{document}\n";
+ "\\begin{document}\n"
+ "\\raggedbottom\n";
QCString documentPre = theTranslator->latexDocumentPre();
if (!documentPre.isEmpty())
{
@@ -889,7 +902,7 @@ void LatexGenerator::writeStyleSheetFile(QFile &f)
writeDefaultStyleSheet(t);
}
-void LatexGenerator::startFile(const char *name,const char *,const char *)
+void LatexGenerator::startFile(const char *name,const char *,const char *,int)
{
#if 0
setEncoding(Config_getString(LATEX_OUTPUT_ENCODING));
@@ -1022,7 +1035,7 @@ void LatexGenerator::startIndexSection(IndexSections is)
bool found=FALSE;
for (nli.toFirst();(nd=nli.current()) && !found;++nli)
{
- if (nd->isLinkableInProject())
+ if (nd->isLinkableInProject() && !nd->isAlias())
{
if (compactLatex) t << "\\doxysection"; else t << "\\chapter";
t << "{"; // Namespace Documentation}\n":
@@ -1040,7 +1053,8 @@ void LatexGenerator::startIndexSection(IndexSections is)
{
if (cd->isLinkableInProject() &&
cd->templateMaster()==0 &&
- !cd->isEmbeddedInOuterScope()
+ !cd->isEmbeddedInOuterScope() &&
+ !cd->isAlias()
)
{
if (compactLatex) t << "\\doxysection"; else t << "\\chapter";
@@ -1191,7 +1205,7 @@ void LatexGenerator::endIndexSection(IndexSections is)
bool found=FALSE;
for (nli.toFirst();(nd=nli.current()) && !found;++nli)
{
- if (nd->isLinkableInProject())
+ if (nd->isLinkableInProject() && !nd->isAlias())
{
t << "}\n\\input{" << nd->getOutputFileBase() << "}\n";
found=TRUE;
@@ -1218,7 +1232,8 @@ void LatexGenerator::endIndexSection(IndexSections is)
{
if (cd->isLinkableInProject() &&
cd->templateMaster()==0 &&
- !cd->isEmbeddedInOuterScope()
+ !cd->isEmbeddedInOuterScope() &&
+ !cd->isAlias()
)
{
t << "}\n\\input{" << cd->getOutputFileBase() << "}\n";
@@ -1229,7 +1244,8 @@ void LatexGenerator::endIndexSection(IndexSections is)
{
if (cd->isLinkableInProject() &&
cd->templateMaster()==0 &&
- !cd->isEmbeddedInOuterScope()
+ !cd->isEmbeddedInOuterScope() &&
+ !cd->isAlias()
)
{
//if (compactLatex) t << "\\input"; else t << "\\include";
@@ -1823,7 +1839,13 @@ void LatexGenerator::endSection(const char *lab,SectionType)
void LatexGenerator::docify(const char *str)
{
- filterLatexString(t,str,m_insideTabbing,FALSE,FALSE);
+ filterLatexString(t,str,
+ m_insideTabbing, // insideTabbing
+ false, // insidePre
+ false, // insideItem
+ m_codeGen.usedTableLevel()>0, // insideTable
+ false // keepSpaces
+ );
}
void LatexGenerator::writeChar(char c)
@@ -1960,13 +1982,13 @@ void LatexGenerator::writeNonBreakableSpace(int)
void LatexGenerator::startDescTable(const char *title)
{
- incUsedTableLevels();
+ m_codeGen.incUsedTableLevel();
t << "\\begin{DoxyEnumFields}{" << title << "}" << endl;
}
void LatexGenerator::endDescTable()
{
- decUsedTableLevels();
+ m_codeGen.decUsedTableLevel();
t << "\\end{DoxyEnumFields}" << endl;
}
@@ -2211,10 +2233,10 @@ void LatexGenerator::exceptionEntry(const char* prefix,bool closeBracket)
t << " ";
}
-void LatexGenerator::writeDoc(DocNode *n,const Definition *ctx,const MemberDef *)
+void LatexGenerator::writeDoc(DocNode *n,const Definition *ctx,const MemberDef *,int)
{
LatexDocVisitor *visitor =
- new LatexDocVisitor(t,*this,ctx?ctx->getDefFileExtension():QCString(""),m_insideTabbing);
+ new LatexDocVisitor(t,m_codeGen,ctx?ctx->getDefFileExtension():QCString(""),m_insideTabbing);
n->accept(visitor);
delete visitor;
}
@@ -2260,21 +2282,6 @@ void LatexGenerator::endConstraintList()
t << "\\end{Desc}" << endl;
}
-void LatexGenerator::startCodeFragment()
-{
- t << "\n\\begin{DoxyCode}{" << usedTableLevels() << "}\n";
- DoxyCodeOpen = TRUE;
-}
-
-void LatexGenerator::endCodeFragment()
-{
- //endCodeLine checks is there is still an open code line, if so closes it.
- endCodeLine();
-
- t << "\\end{DoxyCode}\n";
- DoxyCodeOpen = FALSE;
-}
-
void LatexGenerator::startInlineHeader()
{
if (Config_getBool(COMPACT_LATEX))
@@ -2306,7 +2313,7 @@ void LatexGenerator::lineBreak(const char *)
void LatexGenerator::startMemberDocSimple(bool isEnum)
{
- incUsedTableLevels();
+ m_codeGen.incUsedTableLevel();
if (isEnum)
{
t << "\\begin{DoxyEnumFields}{";
@@ -2322,7 +2329,7 @@ void LatexGenerator::startMemberDocSimple(bool isEnum)
void LatexGenerator::endMemberDocSimple(bool isEnum)
{
- decUsedTableLevels();
+ m_codeGen.decUsedTableLevel();
if (isEnum)
{
t << "\\end{DoxyEnumFields}" << endl;