X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FTextClass.h;h=fd8011328bfd160750d571180c188eb2f4458078;hb=4d5bef1bdcbe7a20d67613a793acb89f0e583bf6;hp=a25338f111dab5169848338da9a133f03e0fc662;hpb=157319b3f65419fa604d29f0741180f0247e8f15;p=lyx.git diff --git a/src/TextClass.h b/src/TextClass.h index a25338f111..fd8011328b 100644 --- a/src/TextClass.h +++ b/src/TextClass.h @@ -10,8 +10,10 @@ #ifndef TEXTCLASS_H #define TEXTCLASS_H +#include "Citation.h" #include "ColorCode.h" #include "Counters.h" +#include "DocumentClassPtr.h" #include "FloatList.h" #include "FontInfo.h" #include "Layout.h" @@ -23,8 +25,6 @@ #include "support/docstring.h" #include "support/types.h" -#include - #include #include #include @@ -245,6 +245,8 @@ protected: bool tex_class_avail_; /// document class prerequisites mutable std::string prerequisites_; + /// The possible cite engine types + std::string opt_enginetype_; /// std::string opt_fontsize_; /// @@ -311,9 +313,15 @@ protected: /// The maximal TocLevel of sectioning layouts int max_toclevel_; /// Citation formatting information - std::map cite_formats_; + std::map > cite_formats_; /// Citation macros - std::map cite_macros_; + std::map > cite_macros_; + /// The default BibTeX bibliography style file + std::string cite_default_biblio_style_; + /// Whether full author lists are supported + bool cite_full_author_list_; + /// The possible citation styles + std::map > cite_styles_; private: /////////////////////////////////////////////////////////////////// // helper routines for reading layout files @@ -339,7 +347,11 @@ private: /// bool readFloat(Lexer &); /// - void readCiteFormat(Lexer &); + bool readCiteEngine(Lexer &); + /// + int readCiteEngineType(Lexer &) const; + /// + bool readCiteFormat(Lexer &); }; @@ -356,7 +368,7 @@ private: /// In the main LyX code, DocumentClass objects are created only by /// DocumentClassBundle, for which see below. /// -class DocumentClass : public TextClass, boost::noncopyable { +class DocumentClass : public TextClass { public: /// virtual ~DocumentClass() {} @@ -390,6 +402,8 @@ public: /// Counters & counters() const { return counters_; } /// + std::string const & opt_enginetype() const { return opt_enginetype_; } + /// std::string const & opt_fontsize() const { return opt_fontsize_; } /// std::string const & opt_pagestyle() const { return opt_pagestyle_; } @@ -439,9 +453,19 @@ public: /// returns true if the class has a ToC structure bool hasTocLevels() const; /// - std::string const & getCiteFormat(std::string const & entry_type) const; + std::string const & getCiteFormat(CiteEngineType const & type, + std::string const & entry, std::string const & fallback = "") const; + /// + std::string const & getCiteMacro(CiteEngineType const & type, + std::string const & macro) const; + /// + std::vector const citeCommands(CiteEngineType const &) const; + /// + std::vector const & citeStyles(CiteEngineType const &) const; /// - std::string const & getCiteMacro(std::string const & macro) const; + std::string const & defaultBiblioStyle() const { return cite_default_biblio_style_; } + /// + bool const & fullAuthorList() const { return cite_full_author_list_; } protected: /// Constructs a DocumentClass based upon a LayoutFile. DocumentClass(LayoutFile const & tc); @@ -450,41 +474,19 @@ protected: private: /// The only class that can create a DocumentClass is /// DocumentClassBundle, which calls the protected constructor. - friend class DocumentClassBundle; + friend DocumentClassPtr + getDocumentClass(LayoutFile const &, LayoutModuleList const &); /// static InsetLayout plain_insetlayout_; }; -/// DocumentClassBundle is a container for DocumentClass objects, so that -/// they stay in memory for use by Insets, CutAndPaste, and the like, even -/// when their associated Buffers are destroyed. -/// FIXME Some sort of garbage collection or reference counting wouldn't -/// be a bad idea here. It might be enough to check when a Buffer is closed -/// (or makeDocumentClass is called) whether the old DocumentClass is in use -/// anywhere. -/// -/// This is a singleton class. Its sole instance is accessed via -/// DocumentClassBundle::get(). -class DocumentClassBundle : boost::noncopyable { -public: - /// \return The sole instance of this class. - static DocumentClassBundle & get(); - /// \return A new DocumentClass based on baseClass, with info added - /// from the modules in modlist. - DocumentClass & makeDocumentClass(LayoutFile const & baseClass, +/// The only way to make a DocumentClass is to call this function. +/// The shared_ptr is needed because DocumentClass objects can be kept +/// in memory long after their associated Buffer is destroyed, mostly +/// on the CutStack. +DocumentClassPtr getDocumentClass(LayoutFile const & baseClass, LayoutModuleList const & modlist); -private: - /// control instantiation - DocumentClassBundle() {} - /// clean up - ~DocumentClassBundle(); - /// \return Reference to a new DocumentClass equal to baseClass - DocumentClass & newClass(LayoutFile const & baseClass); - /// - std::vector documentClasses_; -}; - /// convert page sides option to text 1 or 2 std::ostream & operator<<(std::ostream & os, PageSides p);