1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
2003-08-23 00:17:00 +00:00
|
|
|
/**
|
|
|
|
* \file LaTeXFeatures.h
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Lars Gullik Bjønnes
|
2003-08-23 00:17:00 +00:00
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
#ifndef LATEXFEATURES_H
|
|
|
|
#define LATEXFEATURES_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "OutputParams.h"
|
2006-10-21 19:40:29 +00:00
|
|
|
#include "support/docstring.h"
|
2006-03-28 18:49:46 +00:00
|
|
|
|
2000-03-17 10:14:46 +00:00
|
|
|
#include <set>
|
2001-11-19 15:34:11 +00:00
|
|
|
#include <list>
|
2001-12-28 13:26:54 +00:00
|
|
|
#include <map>
|
2003-10-07 06:45:25 +00:00
|
|
|
#include <string>
|
1999-10-02 16:21:10 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
2003-09-18 14:13:23 +00:00
|
|
|
class Buffer;
|
2002-03-21 17:27:08 +00:00
|
|
|
class BufferParams;
|
2009-06-03 23:44:31 +00:00
|
|
|
class InsetLayout;
|
2005-01-19 15:03:31 +00:00
|
|
|
class Language;
|
1999-10-02 16:21:10 +00:00
|
|
|
|
2001-11-19 15:34:11 +00:00
|
|
|
/** The packages and commands that a buffer needs. This class
|
2004-10-05 10:11:42 +00:00
|
|
|
* contains a list<string>. Each of the LaTeX packages that a buffer needs
|
|
|
|
* should be added with void require(string const & name).
|
|
|
|
*
|
|
|
|
* i.e require("amssymb")
|
|
|
|
*
|
|
|
|
* To add support you should only need to require() the package name as
|
|
|
|
* packages which don't have special requirements are handled automatically.
|
|
|
|
* If your new package does need special consideration you'll need to alter
|
|
|
|
* string const getPackages() const;
|
2007-04-26 04:41:58 +00:00
|
|
|
* Remember to update the validate function in Buffer.cpp and Paragraph.cpp
|
2004-10-05 10:11:42 +00:00
|
|
|
* when you do so.
|
|
|
|
*/
|
2001-11-19 15:34:11 +00:00
|
|
|
class LaTeXFeatures {
|
|
|
|
public:
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2006-03-28 18:49:46 +00:00
|
|
|
LaTeXFeatures(Buffer const &, BufferParams const &,
|
2006-04-05 23:56:29 +00:00
|
|
|
OutputParams const &);
|
2008-09-29 19:18:00 +00:00
|
|
|
/// The color packages
|
|
|
|
std::string const getColorOptions() const;
|
2001-11-09 13:44:48 +00:00
|
|
|
/// The packages needed by the document
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const getPackages() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// The macros definitions needed by the document
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const getMacros() const;
|
2002-05-10 12:58:07 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const getBabelOptions() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// The definitions needed by the document's textclass
|
2006-11-08 17:22:44 +00:00
|
|
|
docstring const getTClassPreamble() const;
|
2009-02-17 20:25:56 +00:00
|
|
|
/// The language dependent definitions needed by the document's textclass
|
|
|
|
docstring const getTClassI18nPreamble(bool use_babel) const;
|
2009-06-05 17:39:00 +00:00
|
|
|
///
|
2009-06-05 19:30:42 +00:00
|
|
|
docstring const getTClassHTMLStyles() const;
|
2006-08-23 12:43:46 +00:00
|
|
|
/// The sgml definitions needed by the document (docbook)
|
2006-10-21 19:40:29 +00:00
|
|
|
docstring const getLyXSGMLEntities() const;
|
2001-11-19 15:34:11 +00:00
|
|
|
/// The SGML Required to include the files added with includeFile();
|
2006-10-21 19:40:29 +00:00
|
|
|
docstring const getIncludedFiles(std::string const & fname) const;
|
2001-11-19 15:34:11 +00:00
|
|
|
/// Include a file for use with the SGML entities
|
2006-10-21 19:40:29 +00:00
|
|
|
void includeFile(docstring const & key, std::string const & name);
|
2001-11-19 15:34:11 +00:00
|
|
|
/// The float definitions.
|
2001-05-09 15:20:58 +00:00
|
|
|
void getFloatDefinitions(std::ostream & os) const;
|
2001-11-19 15:34:11 +00:00
|
|
|
/// Print requirements to lyxerr
|
2001-05-08 17:08:44 +00:00
|
|
|
void showStruct() const;
|
2002-03-21 17:27:08 +00:00
|
|
|
///
|
2007-01-20 17:08:39 +00:00
|
|
|
void addPreambleSnippet(std::string const &);
|
2008-02-01 15:12:04 +00:00
|
|
|
/// Add a feature name requirements
|
2003-10-06 15:43:21 +00:00
|
|
|
void require(std::string const & name);
|
2008-02-01 15:12:04 +00:00
|
|
|
/// Add a set of feature names requirements
|
|
|
|
void require(std::set<std::string> const & names);
|
2005-01-24 17:12:19 +00:00
|
|
|
/// Which of the required packages are installed?
|
|
|
|
static void getAvailable();
|
2007-02-08 10:40:33 +00:00
|
|
|
/// Is the (required) package available?
|
|
|
|
static bool isAvailable(std::string const & name);
|
2007-04-06 09:02:23 +00:00
|
|
|
/// Has the package been required?
|
2003-10-06 15:43:21 +00:00
|
|
|
bool isRequired(std::string const & name) const;
|
2007-05-01 18:12:31 +00:00
|
|
|
/* Is it necessary to load the package? This is true if
|
2007-04-06 09:02:23 +00:00
|
|
|
isRequired is true and the feature is not provided by the
|
|
|
|
textclass.
|
|
|
|
*/
|
|
|
|
bool mustProvide(std::string const & name) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2008-03-02 11:30:50 +00:00
|
|
|
void useFloat(std::string const & name, bool subfloat = false);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2001-11-19 15:34:11 +00:00
|
|
|
void useLanguage(Language const *);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2003-02-16 00:54:43 +00:00
|
|
|
bool hasLanguages() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string getLanguages() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::set<std::string> getEncodingSet(std::string const & doc_encoding) const;
|
2000-05-19 16:46:01 +00:00
|
|
|
///
|
2007-07-11 13:39:08 +00:00
|
|
|
void useLayout(docstring const & lyt);
|
2000-06-12 11:27:15 +00:00
|
|
|
///
|
2009-06-03 23:44:31 +00:00
|
|
|
void useInsetLayout(InsetLayout const & lay);
|
|
|
|
///
|
2003-09-18 14:13:23 +00:00
|
|
|
Buffer const & buffer() const;
|
|
|
|
///
|
2004-04-08 10:09:09 +00:00
|
|
|
void setBuffer(Buffer const &);
|
|
|
|
///
|
2001-11-19 15:34:11 +00:00
|
|
|
BufferParams const & bufferParams() const;
|
2003-05-23 11:18:43 +00:00
|
|
|
/// the return value is dependent upon both LyXRC and LaTeXFeatures.
|
|
|
|
bool useBabel() const;
|
2009-02-07 12:27:24 +00:00
|
|
|
/// are we in a float?
|
|
|
|
bool inFloat() const { return in_float_; }
|
|
|
|
/// are we in a float?
|
|
|
|
void inFloat(bool const b) { in_float_ = b; }
|
2006-03-28 18:49:46 +00:00
|
|
|
/// Runparams that will be used for exporting this file.
|
|
|
|
OutputParams const & runparams() const { return runparams_; }
|
2000-08-07 20:58:24 +00:00
|
|
|
|
2001-11-19 15:34:11 +00:00
|
|
|
private:
|
2009-06-03 23:44:31 +00:00
|
|
|
///
|
2007-07-11 13:39:08 +00:00
|
|
|
std::list<docstring> usedLayouts_;
|
2009-06-03 23:44:31 +00:00
|
|
|
///
|
|
|
|
std::list<docstring> usedInsetLayouts_;
|
2008-02-01 15:12:04 +00:00
|
|
|
/// The features that are needed by the document
|
|
|
|
typedef std::set<std::string> Features;
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
2008-02-01 15:12:04 +00:00
|
|
|
Features features_;
|
|
|
|
/// Static preamble bits from the external material insets
|
|
|
|
typedef std::list<std::string> SnippetList;
|
2000-03-17 10:14:46 +00:00
|
|
|
///
|
2008-02-01 15:12:04 +00:00
|
|
|
SnippetList preamble_snippets_;
|
2005-01-24 17:12:19 +00:00
|
|
|
/// The available (required) packages
|
2008-02-01 15:12:04 +00:00
|
|
|
typedef std::set<std::string> Packages;
|
2005-01-24 17:12:19 +00:00
|
|
|
///
|
2008-02-01 15:12:04 +00:00
|
|
|
static Packages packages_;
|
2003-09-04 01:49:21 +00:00
|
|
|
///
|
2000-04-04 00:19:15 +00:00
|
|
|
typedef std::set<Language const *> LanguageList;
|
2007-05-06 20:26:02 +00:00
|
|
|
/// used languages (only those that are supported by babel)
|
2003-09-18 14:01:02 +00:00
|
|
|
LanguageList UsedLanguages_;
|
2000-06-28 13:35:52 +00:00
|
|
|
///
|
2008-03-02 11:30:50 +00:00
|
|
|
typedef std::map<std::string, bool> UsedFloats;
|
2000-06-28 13:35:52 +00:00
|
|
|
///
|
2003-09-18 14:01:02 +00:00
|
|
|
UsedFloats usedFloats_;
|
2000-07-01 12:54:45 +00:00
|
|
|
///
|
2007-10-31 22:40:34 +00:00
|
|
|
typedef std::map<docstring, std::string> FileMap;
|
2000-07-01 12:54:45 +00:00
|
|
|
///
|
2003-09-18 14:01:02 +00:00
|
|
|
FileMap IncludedFiles_;
|
2004-04-08 10:09:09 +00:00
|
|
|
/** Buffer of the file being processed.
|
|
|
|
* This may be a child buffer of the to-be-exported file and
|
|
|
|
* therefore may not be the buffer that belongs to params_.
|
|
|
|
* Only needed by InsetInclude::validate().
|
|
|
|
*/
|
|
|
|
Buffer const * buffer_;
|
2003-09-18 14:13:23 +00:00
|
|
|
///
|
2003-09-18 14:01:02 +00:00
|
|
|
BufferParams const & params_;
|
2006-03-28 18:49:46 +00:00
|
|
|
/** Some insets need to know details about the to-be-produced file
|
|
|
|
* in validate().
|
2004-01-21 17:52:07 +00:00
|
|
|
*/
|
2006-03-28 18:49:46 +00:00
|
|
|
OutputParams const & runparams_;
|
2009-02-07 12:27:24 +00:00
|
|
|
///
|
|
|
|
bool in_float_;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#endif
|