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
|
|
|
|
2020-11-30 10:32:35 +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>
|
2020-11-22 22:23:39 +00:00
|
|
|
#include <vector>
|
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;
|
2020-11-22 22:23:39 +00:00
|
|
|
class otexstream;
|
|
|
|
class OutputParams;
|
2016-10-17 22:54:37 +00:00
|
|
|
struct TexString;
|
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:
|
2012-07-23 12:34:24 +00:00
|
|
|
/// Which Language package do we use?
|
|
|
|
enum LangPackage {
|
|
|
|
LANG_PACK_NONE,
|
|
|
|
LANG_PACK_BABEL,
|
|
|
|
LANG_PACK_POLYGLOSSIA,
|
|
|
|
LANG_PACK_CUSTOM
|
|
|
|
};
|
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;
|
2014-12-21 11:10:06 +00:00
|
|
|
/// The requested package options
|
|
|
|
std::string const getPackageOptions() 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
|
2016-09-25 10:38:53 +00:00
|
|
|
TexString getMacros() const;
|
2010-11-14 09:54:24 +00:00
|
|
|
/// Extra preamble code before babel is called
|
2016-09-25 10:37:40 +00:00
|
|
|
docstring const getBabelPresettings() const;
|
2010-11-14 09:54:24 +00:00
|
|
|
/// Extra preamble code after babel is called
|
2016-09-25 10:37:40 +00:00
|
|
|
docstring const getBabelPostsettings() const;
|
2010-12-08 18:42:10 +00:00
|
|
|
/// Load AMS packages when appropriate
|
|
|
|
std::string const loadAMSPackages() 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
|
2017-06-06 22:55:23 +00:00
|
|
|
docstring const getTClassI18nPreamble(bool use_babel,
|
|
|
|
bool use_polyglossia, bool use_minted) const;
|
2009-06-05 17:39:00 +00:00
|
|
|
///
|
2009-06-05 19:30:42 +00:00
|
|
|
docstring const getTClassHTMLStyles() const;
|
2009-06-05 19:42:56 +00:00
|
|
|
///
|
|
|
|
docstring const getTClassHTMLPreamble() 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.
|
2016-09-25 10:38:53 +00:00
|
|
|
void getFloatDefinitions(otexstream & 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;
|
2016-09-25 10:38:53 +00:00
|
|
|
/// Add preamble snippet with TexRow information
|
|
|
|
void addPreambleSnippet(TexString snippet, bool allowdupes = false);
|
|
|
|
/// Add preamble snippet without TexRow information
|
2016-09-25 10:37:40 +00:00
|
|
|
void addPreambleSnippet(docstring const & snippet, bool allowdupes = false);
|
2009-12-03 21:06:41 +00:00
|
|
|
///
|
2016-09-25 10:38:53 +00:00
|
|
|
TexString getPreambleSnippets() const;
|
2020-03-14 22:31:25 +00:00
|
|
|
/// Adds CSS information for HTML export.
|
|
|
|
/// Note that addPreambleSnippet is for LaTeX-type export
|
2011-12-06 22:17:13 +00:00
|
|
|
void addCSSSnippet(std::string const &);
|
|
|
|
///
|
2016-09-25 10:37:40 +00:00
|
|
|
docstring getCSSSnippets() 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);
|
2018-04-21 13:47:39 +00:00
|
|
|
/// Add a feature name provision
|
|
|
|
void provide(std::string const & name);
|
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;
|
2012-09-19 13:46:19 +00:00
|
|
|
/** Is this feature already provided
|
|
|
|
* e.g. by the document class?
|
|
|
|
*/
|
|
|
|
bool isProvided(std::string const & name) const;
|
2012-08-08 15:23:02 +00:00
|
|
|
/** Is it necessary to load the package? This is true if
|
2012-09-19 13:46:19 +00:00
|
|
|
isRequired is true and the feature is not already provided
|
2007-04-06 09:02:23 +00:00
|
|
|
*/
|
|
|
|
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;
|
2010-11-22 12:10:16 +00:00
|
|
|
/// check if all used languages are supported by polyglossia
|
2012-06-08 10:54:57 +00:00
|
|
|
bool hasOnlyPolyglossiaLanguages() const;
|
|
|
|
/// check if a language is supported only by polyglossia
|
|
|
|
bool hasPolyglossiaExclusiveLanguages() const;
|
2016-10-27 07:59:01 +00:00
|
|
|
/// A vector of all used languages supported only by polyglossia
|
|
|
|
std::vector<std::string> getPolyglossiaExclusiveLanguages() const;
|
|
|
|
/// A vector of all used languages supported only by babel
|
|
|
|
std::vector<std::string> getBabelExclusiveLanguages() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2012-06-23 11:50:40 +00:00
|
|
|
std::string getBabelLanguages() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2016-11-02 16:07:49 +00:00
|
|
|
std::set<std::string> getPolyglossiaLanguages() const;
|
2010-11-22 12:10:16 +00:00
|
|
|
///
|
2019-08-14 11:10:42 +00:00
|
|
|
std::string getActiveChars() const;
|
|
|
|
///
|
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
|
|
|
///
|
2018-04-21 13:00:42 +00:00
|
|
|
void getFontEncodings(std::vector<std::string> & encodings,
|
|
|
|
bool const onlylangs = false) const;
|
2015-01-24 13:02:16 +00:00
|
|
|
///
|
2020-10-31 17:18:51 +00:00
|
|
|
void useLayout(docstring const & layoutname);
|
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;
|
2012-08-08 15:23:02 +00:00
|
|
|
/** Which language package do we require? \p englishbabel determines
|
|
|
|
* if we require babel even if English is the only language.
|
2012-08-08 15:02:12 +00:00
|
|
|
*/
|
2012-12-23 10:34:38 +00:00
|
|
|
LangPackage langPackage() const;
|
2012-07-23 12:34:24 +00:00
|
|
|
/// Convenience function to test if we use babel
|
2012-12-23 10:34:38 +00:00
|
|
|
bool useBabel() const { return langPackage() == LANG_PACK_BABEL; }
|
2012-07-23 12:34:24 +00:00
|
|
|
/// Convenience function to test if we use polyglossia
|
|
|
|
bool usePolyglossia() const { return langPackage() == LANG_PACK_POLYGLOSSIA; }
|
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; }
|
2016-10-17 01:25:35 +00:00
|
|
|
/// are we in a deleted inset?
|
|
|
|
bool inDeletedInset() const { return in_deleted_inset_; }
|
|
|
|
/// are we in a deleted inset?
|
|
|
|
void inDeletedInset(bool const b) { in_deleted_inset_ = b; }
|
2017-11-19 07:57:58 +00:00
|
|
|
/// set savenote environment (footnote package)
|
|
|
|
std::string saveNoteEnv() const { return savenote_env_; }
|
|
|
|
/// return savenote environment
|
2019-09-13 14:23:49 +00:00
|
|
|
void saveNoteEnv(std::string const & s) { savenote_env_ = s; }
|
2006-03-28 18:49:46 +00:00
|
|
|
/// Runparams that will be used for exporting this file.
|
|
|
|
OutputParams const & runparams() const { return runparams_; }
|
2011-10-18 19:32:02 +00:00
|
|
|
/// Resolve alternatives like "esint|amsmath|wasysym"
|
|
|
|
void resolveAlternatives();
|
2016-09-10 16:32:44 +00:00
|
|
|
/// Expand multiple requirements like "textcomp,lyxmathsym,amstext"
|
|
|
|
void expandMultiples();
|
2010-01-19 19:43:15 +00:00
|
|
|
///
|
|
|
|
void setHTMLTitle(docstring const & t) { htmltitle_ = t; }
|
|
|
|
///
|
|
|
|
docstring const & htmlTitle() const { return htmltitle_; }
|
2019-04-19 15:18:18 +00:00
|
|
|
///
|
|
|
|
bool hasRTLLanguage() const;
|
2000-08-07 20:58:24 +00:00
|
|
|
|
2001-11-19 15:34:11 +00:00
|
|
|
private:
|
2014-07-05 12:37:55 +00:00
|
|
|
///
|
|
|
|
void useLayout(docstring const &, int);
|
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_;
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
2018-04-21 13:47:39 +00:00
|
|
|
typedef std::set<std::string> Features;
|
|
|
|
/// The features that are needed by the document
|
2008-02-01 15:12:04 +00:00
|
|
|
Features features_;
|
2018-04-21 13:47:39 +00:00
|
|
|
/// Features that are provided
|
|
|
|
Features provides_;
|
2009-12-03 21:06:41 +00:00
|
|
|
/// Static preamble bits, from external templates, or anywhere else
|
2016-09-25 10:38:53 +00:00
|
|
|
typedef std::list<TexString> SnippetList;
|
2000-03-17 10:14:46 +00:00
|
|
|
///
|
2008-02-01 15:12:04 +00:00
|
|
|
SnippetList preamble_snippets_;
|
2003-09-04 01:49:21 +00:00
|
|
|
///
|
2011-12-06 22:17:13 +00:00
|
|
|
SnippetList css_snippets_;
|
|
|
|
///
|
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_;
|
2010-01-19 19:43:15 +00:00
|
|
|
///
|
2016-10-17 01:25:35 +00:00
|
|
|
bool in_deleted_inset_;
|
|
|
|
///
|
2010-01-19 19:43:15 +00:00
|
|
|
docstring htmltitle_;
|
2017-11-19 07:57:58 +00:00
|
|
|
///
|
|
|
|
std::string savenote_env_;
|
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
|