Loading src/cite.cpp +64 −79 Original line number Original line Diff line number Diff line Loading @@ -37,6 +37,8 @@ static const char *bib2xhtml_pl = const QCString CiteConsts::fileName("citelist"); const QCString CiteConsts::fileName("citelist"); const QCString CiteConsts::anchorPrefix("CITEREF_"); const QCString CiteConsts::anchorPrefix("CITEREF_"); const QCString bibTmpFile("bibTmpFile_"); const QCString bibTmpDir("bibTmpDir/"); //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- Loading @@ -45,51 +47,6 @@ CiteDict::CiteDict(int size) : m_entries(size, FALSE) m_entries.setAutoDelete(TRUE); m_entries.setAutoDelete(TRUE); } } static QCString getListOfBibFiles(const QCString &sep,bool namesOnly) { QCString result; QStrList &citeDataList = Config_getList("CITE_BIB_FILES"); const char *bibdata = citeDataList.first(); while (bibdata) { int i; QCString bibFile = bibdata; if (namesOnly && bibFile.right(4)==".bib") // strip extension { bibFile = bibFile.left(bibFile.length()-4); } else { if (!namesOnly && bibFile.right(4)!=".bib") bibFile += ".bib"; } if ((i=bibFile.findRev('/'))!=-1) // strip path { bibFile = bibFile.mid(i+1); } if (!bibFile.isEmpty()) { if (namesOnly) // bare names { result+=bibFile; } else // add quotes for paths with spaces { result+="\""+bibFile+"\""; } bibdata = citeDataList.next(); if (bibdata) { result+=sep; } } else { bibdata = citeDataList.next(); } } return result; } void CiteDict::writeLatexBibliography(FTextStream &t) void CiteDict::writeLatexBibliography(FTextStream &t) { { if (m_entries.isEmpty()) if (m_entries.isEmpty()) Loading @@ -108,7 +65,29 @@ void CiteDict::writeLatexBibliography(FTextStream &t) "\\phantomsection\n" "\\phantomsection\n" "\\addcontentsline{toc}{" << unit << "}{" << theTranslator->trCiteReferences() << "}\n" "\\addcontentsline{toc}{" << unit << "}{" << theTranslator->trCiteReferences() << "}\n" "\\bibliographystyle{" << style << "}\n" "\\bibliographystyle{" << style << "}\n" "\\bibliography{" << getListOfBibFiles(",",TRUE) << "}\n" "\\bibliography{"; QStrList &citeDataList = Config_getList("CITE_BIB_FILES"); QCString latexOutputDir = Config_getString("LATEX_OUTPUT")+"/"; int i = 0; const char *bibdata = citeDataList.first(); while (bibdata) { QCString bibFile = bibdata; // Note: file can now have multiple dots if (!bibFile.isEmpty() && bibFile.right(4)!=".bib") bibFile+=".bib"; QFileInfo fi(bibFile); if (fi.exists()) { if (!bibFile.isEmpty()) { if (i) t << ","; i++; t << bibTmpFile << QString().setNum(i); } } bibdata = citeDataList.next(); } t << "}\n" "\n"; "\n"; } } Loading Loading @@ -186,31 +165,29 @@ void CiteDict::generatePage() const f.writeBlock(bstData, bstData.length()); f.writeBlock(bstData, bstData.length()); f.close(); f.close(); // 4. for html we just copy the bib files to the output so that // 4. for all formats we just copy the bib files to as special output directory // bibtex can find them without path (bibtex doesn't support path's // so bibtex can find them without path (bibtex doesn't support paths or // with spaces!) // filenames with spaces!) QList<QCString> tempFiles; // Strictly not required when only latex is generated tempFiles.setAutoDelete(TRUE); QDir thisDir; if (Config_getBool("GENERATE_HTML")) { // copy bib files to the latex output dir QStrList &citeDataList = Config_getList("CITE_BIB_FILES"); QStrList &citeDataList = Config_getList("CITE_BIB_FILES"); QCString bibOutputDir = outputDir+"/"; QCString bibOutputDir = outputDir+"/"+bibTmpDir; QFileInfo fo(bibOutputDir); QCString bibOutputFiles = ""; QDir thisDir; thisDir.mkdir(bibOutputDir); const char *bibdata = citeDataList.first(); const char *bibdata = citeDataList.first(); int i = 0; while (bibdata) while (bibdata) { { QCString bibFile = bibdata; QCString bibFile = bibdata; if (!bibFile.isEmpty() && bibFile.right(4)!=".bib") bibFile+=".bib"; if (!bibFile.isEmpty() && bibFile.right(4)!=".bib") bibFile+=".bib"; QFileInfo fi(bibFile); QFileInfo fi(bibFile); if (fi.exists() && fi.dirPath(TRUE)!=fo.absFilePath()) if (fi.exists()) { { if (!bibFile.isEmpty()) if (!bibFile.isEmpty()) { { QCString destFile=bibOutputDir+fi.fileName().data(); ++i; copyFile(bibFile,destFile); copyFile(bibFile,bibOutputDir + bibTmpFile + QCString().setNum(i) + ".bib"); tempFiles.append(new QCString(destFile)); bibOutputFiles = bibOutputFiles + " " + bibTmpDir + bibTmpFile + QCString().setNum(i) + ".bib"; } } } } else if (!fi.exists()) else if (!fi.exists()) Loading @@ -219,14 +196,13 @@ void CiteDict::generatePage() const } } bibdata = citeDataList.next(); bibdata = citeDataList.next(); } } } QCString oldDir = QDir::currentDirPath().utf8(); QString oldDir = QDir::currentDirPath(); QDir::setCurrent(outputDir); QDir::setCurrent(outputDir); // 5. run bib2xhtml perl script on the generated file which will insert the // 5. run bib2xhtml perl script on the generated file which will insert the // bibliography in citelist.doc // bibliography in citelist.doc portable_system("perl","\""+bib2xhtmlFile+"\" "+getListOfBibFiles(" ",FALSE)+" \""+ portable_system("perl","\""+bib2xhtmlFile+"\" "+bibOutputFiles+" \""+ citeListFile+"\""); citeListFile+"\""); QDir::setCurrent(oldDir); QDir::setCurrent(oldDir); Loading Loading @@ -288,17 +264,22 @@ void CiteDict::generatePage() const // copy bib files to the latex output dir // copy bib files to the latex output dir QStrList &citeDataList = Config_getList("CITE_BIB_FILES"); QStrList &citeDataList = Config_getList("CITE_BIB_FILES"); QCString latexOutputDir = Config_getString("LATEX_OUTPUT")+"/"; QCString latexOutputDir = Config_getString("LATEX_OUTPUT")+"/"; int i = 0; const char *bibdata = citeDataList.first(); const char *bibdata = citeDataList.first(); while (bibdata) while (bibdata) { { QCString bibFile = bibdata; QCString bibFile = bibdata; // Note: file can now have multiple dots if (!bibFile.isEmpty() && bibFile.right(4)!=".bib") bibFile+=".bib"; if (!bibFile.isEmpty() && bibFile.right(4)!=".bib") bibFile+=".bib"; QFileInfo fi(bibFile); QFileInfo fi(bibFile); if (fi.exists()) if (fi.exists()) { { if (!bibFile.isEmpty()) if (!bibFile.isEmpty()) { { copyFile(bibFile,latexOutputDir+fi.fileName().data()); // bug_700510, multile times the same name were overwriting; creating new names // also for names with spaces ++i; copyFile(bibFile,latexOutputDir + bibTmpFile + QCString().setNum(i) + ".bib"); } } } } else else Loading @@ -313,10 +294,14 @@ void CiteDict::generatePage() const thisDir.remove(citeListFile); thisDir.remove(citeListFile); thisDir.remove(doxygenBstFile); thisDir.remove(doxygenBstFile); thisDir.remove(bib2xhtmlFile); thisDir.remove(bib2xhtmlFile); while (!tempFiles.isEmpty()) bibdata = citeDataList.first(); // we might try to remove too many files as empty files didn't get a coresponding new file // but the remove function does not emit an error for it and we don't catch the error return // so no problem. for (unsigned int j = 1; j <= citeDataList.count(); j++) { { QCString *s=tempFiles.take(0); thisDir.remove(bibOutputDir + bibTmpFile + QCString().setNum(j) + ".bib"); thisDir.remove(*s); } } thisDir.rmdir(bibOutputDir); } } src/config.xml +1 −3 Original line number Original line Diff line number Diff line Loading @@ -1145,9 +1145,7 @@ FILE_VERSION_INFO = "cleartool desc -fmt \%Vn" \c bibtex tool to be installed. See also http://en.wikipedia.org/wiki/BibTeX for \c bibtex tool to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. For \f$\mbox{\LaTeX}\f$ the style of the bibliography can be controlled more info. For \f$\mbox{\LaTeX}\f$ the style of the bibliography can be controlled using \ref cfg_latex_bib_style "LATEX_BIB_STYLE". using \ref cfg_latex_bib_style "LATEX_BIB_STYLE". To use this To use this feature you need \c bibtex and \c perl available in the search path. feature you need \c bibtex and \c perl available in the search path. Do not use file names with spaces, \c bibtex cannot handle them. See also \ref cmdcite "\\cite" for info how to create references. See also \ref cmdcite "\\cite" for info how to create references. ]]> ]]> </docs> </docs> Loading Loading
src/cite.cpp +64 −79 Original line number Original line Diff line number Diff line Loading @@ -37,6 +37,8 @@ static const char *bib2xhtml_pl = const QCString CiteConsts::fileName("citelist"); const QCString CiteConsts::fileName("citelist"); const QCString CiteConsts::anchorPrefix("CITEREF_"); const QCString CiteConsts::anchorPrefix("CITEREF_"); const QCString bibTmpFile("bibTmpFile_"); const QCString bibTmpDir("bibTmpDir/"); //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- Loading @@ -45,51 +47,6 @@ CiteDict::CiteDict(int size) : m_entries(size, FALSE) m_entries.setAutoDelete(TRUE); m_entries.setAutoDelete(TRUE); } } static QCString getListOfBibFiles(const QCString &sep,bool namesOnly) { QCString result; QStrList &citeDataList = Config_getList("CITE_BIB_FILES"); const char *bibdata = citeDataList.first(); while (bibdata) { int i; QCString bibFile = bibdata; if (namesOnly && bibFile.right(4)==".bib") // strip extension { bibFile = bibFile.left(bibFile.length()-4); } else { if (!namesOnly && bibFile.right(4)!=".bib") bibFile += ".bib"; } if ((i=bibFile.findRev('/'))!=-1) // strip path { bibFile = bibFile.mid(i+1); } if (!bibFile.isEmpty()) { if (namesOnly) // bare names { result+=bibFile; } else // add quotes for paths with spaces { result+="\""+bibFile+"\""; } bibdata = citeDataList.next(); if (bibdata) { result+=sep; } } else { bibdata = citeDataList.next(); } } return result; } void CiteDict::writeLatexBibliography(FTextStream &t) void CiteDict::writeLatexBibliography(FTextStream &t) { { if (m_entries.isEmpty()) if (m_entries.isEmpty()) Loading @@ -108,7 +65,29 @@ void CiteDict::writeLatexBibliography(FTextStream &t) "\\phantomsection\n" "\\phantomsection\n" "\\addcontentsline{toc}{" << unit << "}{" << theTranslator->trCiteReferences() << "}\n" "\\addcontentsline{toc}{" << unit << "}{" << theTranslator->trCiteReferences() << "}\n" "\\bibliographystyle{" << style << "}\n" "\\bibliographystyle{" << style << "}\n" "\\bibliography{" << getListOfBibFiles(",",TRUE) << "}\n" "\\bibliography{"; QStrList &citeDataList = Config_getList("CITE_BIB_FILES"); QCString latexOutputDir = Config_getString("LATEX_OUTPUT")+"/"; int i = 0; const char *bibdata = citeDataList.first(); while (bibdata) { QCString bibFile = bibdata; // Note: file can now have multiple dots if (!bibFile.isEmpty() && bibFile.right(4)!=".bib") bibFile+=".bib"; QFileInfo fi(bibFile); if (fi.exists()) { if (!bibFile.isEmpty()) { if (i) t << ","; i++; t << bibTmpFile << QString().setNum(i); } } bibdata = citeDataList.next(); } t << "}\n" "\n"; "\n"; } } Loading Loading @@ -186,31 +165,29 @@ void CiteDict::generatePage() const f.writeBlock(bstData, bstData.length()); f.writeBlock(bstData, bstData.length()); f.close(); f.close(); // 4. for html we just copy the bib files to the output so that // 4. for all formats we just copy the bib files to as special output directory // bibtex can find them without path (bibtex doesn't support path's // so bibtex can find them without path (bibtex doesn't support paths or // with spaces!) // filenames with spaces!) QList<QCString> tempFiles; // Strictly not required when only latex is generated tempFiles.setAutoDelete(TRUE); QDir thisDir; if (Config_getBool("GENERATE_HTML")) { // copy bib files to the latex output dir QStrList &citeDataList = Config_getList("CITE_BIB_FILES"); QStrList &citeDataList = Config_getList("CITE_BIB_FILES"); QCString bibOutputDir = outputDir+"/"; QCString bibOutputDir = outputDir+"/"+bibTmpDir; QFileInfo fo(bibOutputDir); QCString bibOutputFiles = ""; QDir thisDir; thisDir.mkdir(bibOutputDir); const char *bibdata = citeDataList.first(); const char *bibdata = citeDataList.first(); int i = 0; while (bibdata) while (bibdata) { { QCString bibFile = bibdata; QCString bibFile = bibdata; if (!bibFile.isEmpty() && bibFile.right(4)!=".bib") bibFile+=".bib"; if (!bibFile.isEmpty() && bibFile.right(4)!=".bib") bibFile+=".bib"; QFileInfo fi(bibFile); QFileInfo fi(bibFile); if (fi.exists() && fi.dirPath(TRUE)!=fo.absFilePath()) if (fi.exists()) { { if (!bibFile.isEmpty()) if (!bibFile.isEmpty()) { { QCString destFile=bibOutputDir+fi.fileName().data(); ++i; copyFile(bibFile,destFile); copyFile(bibFile,bibOutputDir + bibTmpFile + QCString().setNum(i) + ".bib"); tempFiles.append(new QCString(destFile)); bibOutputFiles = bibOutputFiles + " " + bibTmpDir + bibTmpFile + QCString().setNum(i) + ".bib"; } } } } else if (!fi.exists()) else if (!fi.exists()) Loading @@ -219,14 +196,13 @@ void CiteDict::generatePage() const } } bibdata = citeDataList.next(); bibdata = citeDataList.next(); } } } QCString oldDir = QDir::currentDirPath().utf8(); QString oldDir = QDir::currentDirPath(); QDir::setCurrent(outputDir); QDir::setCurrent(outputDir); // 5. run bib2xhtml perl script on the generated file which will insert the // 5. run bib2xhtml perl script on the generated file which will insert the // bibliography in citelist.doc // bibliography in citelist.doc portable_system("perl","\""+bib2xhtmlFile+"\" "+getListOfBibFiles(" ",FALSE)+" \""+ portable_system("perl","\""+bib2xhtmlFile+"\" "+bibOutputFiles+" \""+ citeListFile+"\""); citeListFile+"\""); QDir::setCurrent(oldDir); QDir::setCurrent(oldDir); Loading Loading @@ -288,17 +264,22 @@ void CiteDict::generatePage() const // copy bib files to the latex output dir // copy bib files to the latex output dir QStrList &citeDataList = Config_getList("CITE_BIB_FILES"); QStrList &citeDataList = Config_getList("CITE_BIB_FILES"); QCString latexOutputDir = Config_getString("LATEX_OUTPUT")+"/"; QCString latexOutputDir = Config_getString("LATEX_OUTPUT")+"/"; int i = 0; const char *bibdata = citeDataList.first(); const char *bibdata = citeDataList.first(); while (bibdata) while (bibdata) { { QCString bibFile = bibdata; QCString bibFile = bibdata; // Note: file can now have multiple dots if (!bibFile.isEmpty() && bibFile.right(4)!=".bib") bibFile+=".bib"; if (!bibFile.isEmpty() && bibFile.right(4)!=".bib") bibFile+=".bib"; QFileInfo fi(bibFile); QFileInfo fi(bibFile); if (fi.exists()) if (fi.exists()) { { if (!bibFile.isEmpty()) if (!bibFile.isEmpty()) { { copyFile(bibFile,latexOutputDir+fi.fileName().data()); // bug_700510, multile times the same name were overwriting; creating new names // also for names with spaces ++i; copyFile(bibFile,latexOutputDir + bibTmpFile + QCString().setNum(i) + ".bib"); } } } } else else Loading @@ -313,10 +294,14 @@ void CiteDict::generatePage() const thisDir.remove(citeListFile); thisDir.remove(citeListFile); thisDir.remove(doxygenBstFile); thisDir.remove(doxygenBstFile); thisDir.remove(bib2xhtmlFile); thisDir.remove(bib2xhtmlFile); while (!tempFiles.isEmpty()) bibdata = citeDataList.first(); // we might try to remove too many files as empty files didn't get a coresponding new file // but the remove function does not emit an error for it and we don't catch the error return // so no problem. for (unsigned int j = 1; j <= citeDataList.count(); j++) { { QCString *s=tempFiles.take(0); thisDir.remove(bibOutputDir + bibTmpFile + QCString().setNum(j) + ".bib"); thisDir.remove(*s); } } thisDir.rmdir(bibOutputDir); } }
src/config.xml +1 −3 Original line number Original line Diff line number Diff line Loading @@ -1145,9 +1145,7 @@ FILE_VERSION_INFO = "cleartool desc -fmt \%Vn" \c bibtex tool to be installed. See also http://en.wikipedia.org/wiki/BibTeX for \c bibtex tool to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. For \f$\mbox{\LaTeX}\f$ the style of the bibliography can be controlled more info. For \f$\mbox{\LaTeX}\f$ the style of the bibliography can be controlled using \ref cfg_latex_bib_style "LATEX_BIB_STYLE". using \ref cfg_latex_bib_style "LATEX_BIB_STYLE". To use this To use this feature you need \c bibtex and \c perl available in the search path. feature you need \c bibtex and \c perl available in the search path. Do not use file names with spaces, \c bibtex cannot handle them. See also \ref cmdcite "\\cite" for info how to create references. See also \ref cmdcite "\\cite" for info how to create references. ]]> ]]> </docs> </docs> Loading