lyx_mirror/src/LaTeXPackages.cpp
Georg Baum 0dee3eff18 Fix bug #4213: Change tracking support for tex2lyx.
Of course this will only work if output_changes was true when creating the
.tex file.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40139 a592a061-630c-0410-9148-cb99ea01b6c8
2011-11-06 17:03:59 +00:00

76 lines
1.3 KiB
C++

/**
* \file LaTeXPackages.cpp
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author José Matos
* \author Lars Gullik Bjønnes
* \author Jean-Marc Lasgouttes
* \author Jürgen Vigna
* \author André Pönitz
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "LaTeXPackages.h"
#include "Lexer.h"
#include "support/FileName.h"
#include "support/filetools.h"
#include "support/lstrings.h"
using namespace std;
using namespace lyx::support;
namespace lyx {
LaTeXPackages::Packages LaTeXPackages::packages_;
void LaTeXPackages::getAvailable()
{
Lexer lex;
support::FileName const real_file = libFileSearch("", "packages.lst");
if (real_file.empty())
return;
lex.setFile(real_file);
if (!lex.isOK())
return;
// Make sure that we are clean
packages_.clear();
bool finished = false;
// Parse config-file
while (lex.isOK() && !finished) {
switch (lex.lex()) {
case Lexer::LEX_FEOF:
finished = true;
break;
default:
packages_.insert(lex.getString());
}
}
}
bool LaTeXPackages::isAvailable(string const & name)
{
if (packages_.empty())
getAvailable();
string n = name;
if (suffixIs(n, ".sty"))
n.erase(name.length() - 4);
return packages_.find(n) != packages_.end();
}
} // namespace lyx