Doxygen
latexgen.cpp 文件参考
#include <cstdlib>
#include <sstream>
#include "latexgen.h"
#include "config.h"
#include "message.h"
#include "doxygen.h"
#include "util.h"
#include "diagram.h"
#include "language.h"
#include "version.h"
#include "dot.h"
#include "dotcallgraph.h"
#include "dotclassgraph.h"
#include "dotdirdeps.h"
#include "dotgroupcollaboration.h"
#include "dotincldepgraph.h"
#include "pagedef.h"
#include "docparser.h"
#include "latexdocvisitor.h"
#include "dirdef.h"
#include "cite.h"
#include "groupdef.h"
#include "classlist.h"
#include "namespacedef.h"
#include "filename.h"
#include "resourcemgr.h"
#include "portable.h"
#include "fileinfo.h"
#include "utf8.h"
+ latexgen.cpp 的引用(Include)关系图:

浏览源代码.

宏定义

#define COPYCHAR()
 

函数

static void writeLatexMakefile ()
 
static void writeMakeBat ()
 
static void writeDefaultStyleSheet (TextStream &t)
 
static QCString extraLatexStyleSheet ()
 
static QCString makeIndex ()
 
static QCString substituteLatexKeywords (const QCString &str, const QCString &title)
 

变量

static QCString g_header
 
static QCString g_footer
 

宏定义说明

◆ COPYCHAR

#define COPYCHAR ( )
值:
do { \
int bytes = getUTF8CharNumBytes(c); \
if (lresult < (i + bytes + 1)) \
{ \
lresult += 512; \
result = (signed char *)realloc(result, lresult); \
} \
for (int j=0; j<bytes && *p; j++) \
{ \
result[i++]=*p++; \
} \
m_col++; \
} while(0)

函数说明

◆ extraLatexStyleSheet()

static QCString extraLatexStyleSheet ( )
static

在文件 latexgen.cpp558 行定义.

559 {
560  QCString result;
561  const StringVector &extraLatexStyles = Config_getList(LATEX_EXTRA_STYLESHEET);
562  for (const auto &fileName : extraLatexStyles)
563  {
564  if (!fileName.empty())
565  {
566  FileInfo fi(fileName);
567  if (fi.exists())
568  {
569  result += "\\usepackage{";
570  if (checkExtension(fi.fileName().c_str(), LATEX_STYLE_EXTENSION))
571  {
572  // strip the extension, it will be added by the usepackage in the tex conversion process
573  result += stripExtensionGeneral(fi.fileName().c_str(), LATEX_STYLE_EXTENSION);
574  }
575  else
576  {
577  result += fi.fileName();
578  }
579  result += "}\n";
580  }
581  }
582  }
583  return result;
584 }

引用了 checkExtension(), Config_getList, FileInfo::exists(), FileInfo::fileName(), LATEX_STYLE_EXTENSION , 以及 stripExtensionGeneral().

被这些函数引用 substituteLatexKeywords().

◆ makeIndex()

static QCString makeIndex ( )
static

在文件 latexgen.cpp586 行定义.

587 {
588  QCString result;
589  QCString latex_mkidx_command = Config_getString(LATEX_MAKEINDEX_CMD);
590  if (!latex_mkidx_command.isEmpty())
591  {
592  if (latex_mkidx_command[0] == '\\')
593  result += latex_mkidx_command;
594  else
595  result += "\\"+latex_mkidx_command;
596  }
597  else
598  {
599  result += "\\makeindex";
600  }
601  return result;
602 }

引用了 Config_getString , 以及 QCString::isEmpty().

被这些函数引用 substituteLatexKeywords().

◆ substituteLatexKeywords()

static QCString substituteLatexKeywords ( const QCString str,
const QCString title 
)
static

在文件 latexgen.cpp604 行定义.

606 {
607  bool compactLatex = Config_getBool(COMPACT_LATEX);
608  bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
609  bool usePdfLatex = Config_getBool(USE_PDFLATEX);
610  bool latexBatchmode = Config_getBool(LATEX_BATCHMODE);
611  QCString paperType = Config_getEnumAsString(PAPER_TYPE);
612 
613  QCString style = Config_getString(LATEX_BIB_STYLE);
614  if (style.isEmpty())
615  {
616  style="plain";
617  }
618 
619  TextStream tg;
620  bool timeStamp = Config_getBool(LATEX_TIMESTAMP);
621  QCString generatedBy;
622  if (timeStamp)
623  {
624  generatedBy = theTranslator->trGeneratedAt(dateToString(TRUE).data(),
625  Config_getString(PROJECT_NAME).data());
626  }
627  else
628  {
629  generatedBy = theTranslator->trGeneratedBy();
630  }
631  filterLatexString(tg, generatedBy,
632  false, // insideTabbing
633  false, // insidePre
634  false, // insideItem
635  false, // insideTable
636  false // keepSpaces
637  );
638  generatedBy = tg.str();
639 
640  QCString latexFontenc = theTranslator->latexFontenc();
641 
642  QCString latexEmojiDirectory = Config_getString(LATEX_EMOJI_DIRECTORY);
643  if (latexEmojiDirectory.isEmpty()) latexEmojiDirectory = ".";
644  latexEmojiDirectory = substitute(latexEmojiDirectory,"\\","/");
645 
646  TextStream tg1;
648  QCString extraLatexPackages = tg1.str();
649 
650  TextStream tg2;
652  QCString latexSpecialFormulaChars = tg2.str();
653 
654  QCString formulaMacrofile = Config_getString(FORMULA_MACROFILE);
655  if (!formulaMacrofile.isEmpty())
656  {
657  FileInfo fi(formulaMacrofile.str());
658  formulaMacrofile=fi.absFilePath();
659  QCString stripMacroFile = fi.fileName();
660  copyFile(formulaMacrofile,Config_getString(LATEX_OUTPUT) + "/" + stripMacroFile);
661  }
662 
663  // first substitute generic keywords
664  QCString result = substituteKeywords(str,title,
665  convertToLaTeX(Config_getString(PROJECT_NAME)),
666  convertToLaTeX(Config_getString(PROJECT_NUMBER)),
667  convertToLaTeX(Config_getString(PROJECT_BRIEF)));
668 
669  // additional LaTeX only keywords
670  result = substitute(result,"$latexdocumentpre",theTranslator->latexDocumentPre());
671  result = substitute(result,"$latexdocumentpost",theTranslator->latexDocumentPost());
672  result = substitute(result,"$generatedby",generatedBy);
673  result = substitute(result,"$latexbibstyle",style);
674  result = substitute(result,"$latexcitereference",theTranslator->trCiteReferences());
675  result = substitute(result,"$latexbibfiles",CitationManager::instance().latexBibFiles());
676  result = substitute(result,"$papertype",paperType+"paper");
677  result = substitute(result,"$extralatexstylesheet",extraLatexStyleSheet());
678  result = substitute(result,"$languagesupport",theTranslator->latexLanguageSupportCommand());
679  result = substitute(result,"$latexfontenc",latexFontenc);
680  result = substitute(result,"$latexfont",theTranslator->latexFont());
681  result = substitute(result,"$latexemojidirectory",latexEmojiDirectory);
682  result = substitute(result,"$makeindex",makeIndex());
683  result = substitute(result,"$extralatexpackages",extraLatexPackages);
684  result = substitute(result,"$latexspecialformulachars",latexSpecialFormulaChars);
685  result = substitute(result,"$formulamacrofile",formulaMacrofile);
686 
687  // additional LaTeX only conditional blocks
688  result = selectBlock(result,"CITATIONS_PRESENT", !CitationManager::instance().isEmpty(),OutputGenerator::Latex);
689  result = selectBlock(result,"COMPACT_LATEX",compactLatex,OutputGenerator::Latex);
690  result = selectBlock(result,"PDF_HYPERLINKS",pdfHyperlinks,OutputGenerator::Latex);
691  result = selectBlock(result,"USE_PDFLATEX",usePdfLatex,OutputGenerator::Latex);
692  result = selectBlock(result,"LATEX_TIMESTAMP",timeStamp,OutputGenerator::Latex);
693  result = selectBlock(result,"LATEX_BATCHMODE",latexBatchmode,OutputGenerator::Latex);
694  result = selectBlock(result,"LATEX_FONTENC",!latexFontenc.isEmpty(),OutputGenerator::Latex);
695  result = selectBlock(result,"FORMULA_MACROFILE",!formulaMacrofile.isEmpty(),OutputGenerator::Latex);
696 
697  result = removeEmptyLines(result);
698 
699  return result;
700 }

引用了 FileInfo::absFilePath(), Config_getBool, Config_getEnumAsString, Config_getString, convertToLaTeX(), copyFile(), dateToString(), extraLatexStyleSheet(), FileInfo::fileName(), filterLatexString(), CitationManager::instance(), QCString::isEmpty(), OutputGenerator::Latex, Translator::latexDocumentPost(), Translator::latexDocumentPre(), Translator::latexFont(), Translator::latexFontenc(), Translator::latexLanguageSupportCommand(), makeIndex(), removeEmptyLines(), selectBlock(), TextStream::str(), QCString::str(), substitute(), substituteKeywords(), theTranslator, Translator::trCiteReferences(), Translator::trGeneratedAt(), Translator::trGeneratedBy(), TRUE, writeExtraLatexPackages() , 以及 writeLatexSpecialFormulaChars().

被这些函数引用 LatexGenerator::endIndexSection() , 以及 LatexGenerator::startIndexSection().

◆ writeDefaultStyleSheet()

static void writeDefaultStyleSheet ( TextStream t)
static

在文件 latexgen.cpp506 行定义.

507 {
508  t << ResourceMgr::instance().getAsString("doxygen.sty");
509 }

引用了 ResourceMgr::getAsString() , 以及 ResourceMgr::instance().

被这些函数引用 LatexGenerator::writeStyleInfo() , 以及 LatexGenerator::writeStyleSheetFile().

◆ writeLatexMakefile()

static void writeLatexMakefile ( )
static

在文件 latexgen.cpp287 行定义.

288 {
289  bool generateBib = !CitationManager::instance().isEmpty();
290  QCString fileName=Config_getString(LATEX_OUTPUT)+"/Makefile";
291  std::ofstream f(fileName.str(),std::ofstream::out | std::ofstream::binary);
292  if (!f.is_open())
293  {
294  term("Could not open file %s for writing\n",qPrint(fileName));
295  }
296  TextStream t(&f);
297  // inserted by KONNO Akihisa <konno@researchers.jp> 2002-03-05
298  QCString latex_command = theTranslator->latexCommandName();
299  QCString mkidx_command = Config_getString(MAKEINDEX_CMD_NAME);
300  // end insertion by KONNO Akihisa <konno@researchers.jp> 2002-03-05
301  if (!Config_getBool(USE_PDFLATEX)) // use plain old latex
302  {
303  t << "LATEX_CMD=" << latex_command << "\n"
304  << "\n"
305  << "all: refman.dvi\n"
306  << "\n"
307  << "ps: refman.ps\n"
308  << "\n"
309  << "pdf: refman.pdf\n"
310  << "\n"
311  << "ps_2on1: refman_2on1.ps\n"
312  << "\n"
313  << "pdf_2on1: refman_2on1.pdf\n"
314  << "\n"
315  << "refman.ps: refman.dvi\n"
316  << "\tdvips -o refman.ps refman.dvi\n"
317  << "\n";
318  t << "refman.pdf: refman.ps\n";
319  t << "\tps2pdf refman.ps refman.pdf\n\n";
320  t << "refman.dvi: clean refman.tex doxygen.sty\n"
321  << "\techo \"Running latex...\"\n"
322  << "\t$(LATEX_CMD) refman.tex\n"
323  << "\techo \"Running makeindex...\"\n"
324  << "\t" << mkidx_command << " refman.idx\n";
325  if (generateBib)
326  {
327  t << "\techo \"Running bibtex...\"\n";
328  t << "\tbibtex refman\n";
329  t << "\techo \"Rerunning latex....\"\n";
330  t << "\t$(LATEX_CMD) refman.tex\n";
331  }
332  t << "\techo \"Rerunning latex....\"\n"
333  << "\t$(LATEX_CMD) refman.tex\n"
334  << "\tlatex_count=8 ; \\\n"
335  << "\twhile egrep -s 'Rerun (LaTeX|to get cross-references right)' refman.log && [ $$latex_count -gt 0 ] ;\\\n"
336  << "\t do \\\n"
337  << "\t echo \"Rerunning latex....\" ;\\\n"
338  << "\t $(LATEX_CMD) refman.tex ; \\\n"
339  << "\t latex_count=`expr $$latex_count - 1` ;\\\n"
340  << "\t done\n"
341  << "\t" << mkidx_command << " refman.idx\n"
342  << "\t$(LATEX_CMD) refman.tex\n\n"
343  << "refman_2on1.ps: refman.ps\n"
344  << "\tpsnup -2 refman.ps >refman_2on1.ps\n"
345  << "\n"
346  << "refman_2on1.pdf: refman_2on1.ps\n"
347  << "\tps2pdf refman_2on1.ps refman_2on1.pdf\n";
348  }
349  else // use pdflatex for higher quality output
350  {
351  t << "LATEX_CMD=" << latex_command << "\n"
352  << "\n";
353  t << "all: refman.pdf\n\n"
354  << "pdf: refman.pdf\n\n";
355  t << "refman.pdf: clean refman.tex\n";
356  t << "\t$(LATEX_CMD) refman\n";
357  t << "\t" << mkidx_command << " refman.idx\n";
358  if (generateBib)
359  {
360  t << "\tbibtex refman\n";
361  t << "\t$(LATEX_CMD) refman\n";
362  }
363  t << "\t$(LATEX_CMD) refman\n"
364  << "\tlatex_count=8 ; \\\n"
365  << "\twhile egrep -s 'Rerun (LaTeX|to get cross-references right)' refman.log && [ $$latex_count -gt 0 ] ;\\\n"
366  << "\t do \\\n"
367  << "\t echo \"Rerunning latex....\" ;\\\n"
368  << "\t $(LATEX_CMD) refman ;\\\n"
369  << "\t latex_count=`expr $$latex_count - 1` ;\\\n"
370  << "\t done\n"
371  << "\t" << mkidx_command << " refman.idx\n"
372  << "\t$(LATEX_CMD) refman\n\n";
373  }
374 
375  t << "\n"
376  << "clean:\n"
377  << "\trm -f "
378  << "*.ps *.dvi *.aux *.toc *.idx *.ind *.ilg *.log *.out *.brf *.blg *.bbl refman.pdf\n";
379 }

引用了 Config_getBool, Config_getString, CitationManager::instance(), CitationManager::isEmpty(), Translator::latexCommandName(), qPrint(), QCString::str(), term() , 以及 theTranslator.

被这些函数引用 LatexGenerator::init().

◆ writeMakeBat()

static void writeMakeBat ( )
static

在文件 latexgen.cpp381 行定义.

382 {
383 #if defined(_MSC_VER)
384  QCString dir=Config_getString(LATEX_OUTPUT);
385  QCString fileName=dir+"/make.bat";
386  QCString latex_command = theTranslator->latexCommandName();
387  QCString mkidx_command = Config_getString(MAKEINDEX_CMD_NAME);
388  bool generateBib = !CitationManager::instance().isEmpty();
389  std::ofstream t(fileName.str(),std::ofstream::out | std::ofstream::binary);
390  if (!t.is_open())
391  {
392  term("Could not open file %s for writing\n",qPrint(fileName));
393  }
394  t << "set Dir_Old=%cd%\r\n";
395  t << "cd /D %~dp0\r\n\r\n";
396  t << "del /s /f *.ps *.dvi *.aux *.toc *.idx *.ind *.ilg *.log *.out *.brf *.blg *.bbl refman.pdf\r\n\r\n";
397  if (!Config_getBool(USE_PDFLATEX)) // use plain old latex
398  {
399  t << "set LATEX_CMD=" << latex_command << "\r\n";
400  t << "%LATEX_CMD% refman.tex\r\n";
401  t << "echo ----\r\n";
402  t << mkidx_command << " refman.idx\r\n";
403  if (generateBib)
404  {
405  t << "bibtex refman\r\n";
406  t << "echo ----\r\n";
407  t << "\t%LATEX_CMD% refman.tex\r\n";
408  }
409  t << "setlocal enabledelayedexpansion\r\n";
410  t << "set count=8\r\n";
411  t << ":repeat\r\n";
412  t << "set content=X\r\n";
413  t << "for /F \"tokens=*\" %%T in ( 'findstr /C:\"Rerun LaTeX\" refman.log' ) do set content=\"%%~T\"\r\n";
414  t << "if !content! == X for /F \"tokens=*\" %%T in ( 'findstr /C:\"Rerun to get cross-references right\" refman.log' ) do set content=\"%%~T\"\r\n";
415  t << "if !content! == X goto :skip\r\n";
416  t << "set /a count-=1\r\n";
417  t << "if !count! EQU 0 goto :skip\r\n\r\n";
418  t << "echo ----\r\n";
419  t << "%LATEX_CMD% refman.tex\r\n";
420  t << "goto :repeat\r\n";
421  t << ":skip\r\n";
422  t << "endlocal\r\n";
423  t << mkidx_command << " refman.idx\r\n";
424  t << "%LATEX_CMD% refman.tex\r\n";
425  t << "dvips -o refman.ps refman.dvi\r\n";
427  t << " -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite "
428  "-sOutputFile=refman.pdf -c save pop -f refman.ps\r\n";
429  }
430  else // use pdflatex
431  {
432  t << "set LATEX_CMD=" << latex_command << "\r\n";
433  t << "%LATEX_CMD% refman\r\n";
434  t << "echo ----\r\n";
435  t << mkidx_command << " refman.idx\r\n";
436  if (generateBib)
437  {
438  t << "bibtex refman\r\n";
439  t << "%LATEX_CMD% refman\r\n";
440  }
441  t << "echo ----\r\n";
442  t << "%LATEX_CMD% refman\r\n\r\n";
443  t << "setlocal enabledelayedexpansion\r\n";
444  t << "set count=8\r\n";
445  t << ":repeat\r\n";
446  t << "set content=X\r\n";
447  t << "for /F \"tokens=*\" %%T in ( 'findstr /C:\"Rerun LaTeX\" refman.log' ) do set content=\"%%~T\"\r\n";
448  t << "if !content! == X for /F \"tokens=*\" %%T in ( 'findstr /C:\"Rerun to get cross-references right\" refman.log' ) do set content=\"%%~T\"\r\n";
449  t << "if !content! == X goto :skip\r\n";
450  t << "set /a count-=1\r\n";
451  t << "if !count! EQU 0 goto :skip\r\n\r\n";
452  t << "echo ----\r\n";
453  t << "%LATEX_CMD% refman\r\n";
454  t << "goto :repeat\r\n";
455  t << ":skip\r\n";
456  t << "endlocal\r\n";
457  t << mkidx_command << " refman.idx\r\n";
458  t << "%LATEX_CMD% refman\r\n";
459  t << "cd /D %Dir_Old%\r\n";
460  t << "set Dir_Old=\r\n";
461  }
462 #endif
463 }

引用了 Config_getBool, Config_getString, Portable::ghostScriptCommand(), CitationManager::instance(), CitationManager::isEmpty(), Translator::latexCommandName(), qPrint(), QCString::str(), term() , 以及 theTranslator.

被这些函数引用 LatexGenerator::init().

变量说明

◆ g_footer

QCString g_footer
static

在文件 latexgen.cpp50 行定义.

被这些函数引用 LatexGenerator::endIndexSection() , 以及 LatexGenerator::init().

◆ g_header

QCString g_header
static

在文件 latexgen.cpp49 行定义.

被这些函数引用 LatexGenerator::init() , 以及 LatexGenerator::startIndexSection().

selectBlock
QCString selectBlock(const QCString &s, const QCString &name, bool enable, OutputGenerator::OutputType o)
Definition: util.cpp:7209
StringVector
std::vector< std::string > StringVector
Definition: containers.h:32
ResourceMgr::instance
static ResourceMgr & instance()
Returns the one and only instance of this class
Definition: resourcemgr.cpp:32
Translator::trGeneratedBy
virtual QCString trGeneratedBy()=0
Translator::latexFontenc
virtual QCString latexFontenc()
Definition: translator.h:66
stripExtensionGeneral
QCString stripExtensionGeneral(const QCString &fName, const QCString &ext)
Definition: util.cpp:5285
ResourceMgr::getAsString
QCString getAsString(const QCString &name) const
Gets the resource data as a C string
Definition: resourcemgr.cpp:192
Translator::latexCommandName
virtual QCString latexCommandName()
Definition: translator.h:85
QCString::isEmpty
bool isEmpty() const
Returns TRUE iff the string is empty
Definition: qcstring.h:144
copyFile
bool copyFile(const QCString &src, const QCString &dest)
Copies the contents of file with name src to the newly created file with name dest.
Definition: util.cpp:6439
QCString::str
std::string str() const
Definition: qcstring.h:442
TextStream
Text streaming class that buffers data.
Definition: textstream.h:33
CitationManager::instance
static CitationManager & instance()
Definition: cite.cpp:56
convertToLaTeX
QCString convertToLaTeX(const QCString &s, bool insideTabbing, bool keepSpaces)
Definition: util.cpp:4161
Translator::trGeneratedAt
virtual QCString trGeneratedAt(const QCString &date, const QCString &projName)=0
Translator::latexFont
virtual QCString latexFont()
Definition: translator.h:67
dateToString
QCString dateToString(bool includeTime)
Definition: util.cpp:1470
removeEmptyLines
QCString removeEmptyLines(const QCString &s)
Definition: util.cpp:7251
OutputGenerator::Latex
@ Latex
Definition: outputgen.h:333
Portable::ghostScriptCommand
const char * ghostScriptCommand()
Definition: portable.cpp:410
makeIndex
static QCString makeIndex()
Definition: latexgen.cpp:586
theTranslator
Translator * theTranslator
Definition: language.cpp:156
Config_getEnumAsString
#define Config_getEnumAsString(name)
Definition: config.h:36
CitationManager::isEmpty
bool isEmpty() const
return TRUE if there are no citations.
Definition: cite.cpp:90
LATEX_STYLE_EXTENSION
#define LATEX_STYLE_EXTENSION
Definition: latexgen.h:24
TRUE
#define TRUE
Definition: qcstring.h:36
TextStream::str
std::string str() const
Return the contents of the buffer as a std::string object
Definition: textstream.h:208
writeLatexSpecialFormulaChars
void writeLatexSpecialFormulaChars(TextStream &t)
Definition: util.cpp:7084
writeExtraLatexPackages
void writeExtraLatexPackages(TextStream &t)
Definition: util.cpp:7066
getUTF8CharNumBytes
uint8_t getUTF8CharNumBytes(char c)
Returns the number of bytes making up a single UTF8 character given the first byte in the sequence.
Definition: utf8.cpp:23
substitute
QCString substitute(const QCString &s, const QCString &src, const QCString &dst)
substitute all occurrences of src in s by dst
Definition: qcstring.cpp:465
Translator::latexLanguageSupportCommand
virtual QCString latexLanguageSupportCommand()=0
Translator::trCiteReferences
virtual QCString trCiteReferences()=0
substituteKeywords
QCString substituteKeywords(const QCString &s, const QCString &title, const QCString &projName, const QCString &projNum, const QCString &projBrief)
Definition: util.cpp:3335
Config_getBool
#define Config_getBool(name)
Definition: config.h:33
term
void term(const char *fmt,...)
Definition: message.cpp:220
extraLatexStyleSheet
static QCString extraLatexStyleSheet()
Definition: latexgen.cpp:558
FileInfo
Minimal replacement for QFileInfo.
Definition: fileinfo.h:22
qPrint
const char * qPrint(const char *s)
Definition: qcstring.h:589
Config_getString
#define Config_getString(name)
Definition: config.h:32
Translator::latexDocumentPre
virtual QCString latexDocumentPre()
Definition: translator.h:76
checkExtension
bool checkExtension(const QCString &fName, const QCString &ext)
Definition: util.cpp:5270
filterLatexString
void filterLatexString(TextStream &t, const QCString &str, bool insideTabbing, bool insidePre, bool insideItem, bool insideTable, bool keepSpaces)
Definition: util.cpp:4934
Translator::latexDocumentPost
virtual QCString latexDocumentPost()
Definition: translator.h:81
Config_getList
#define Config_getList(name)
Definition: config.h:37
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108