+ void readCharStyle(Lexer &, std::string const &);
+ ///
+ void readFloat(Lexer &);
+};
+
+
+/// A DocumentClass represents the layout information associated with a
+/// Buffer. It is based upon a LayoutFile, but may be modified by loading
+/// various Modules.
+///
+/// In that regard, DocumentClass objects are "dynamic". But this is really
+/// an illusion, since DocumentClass objects are not (currently) changed
+/// when, say, a new Module is loaded. Rather, the old DocumentClass is
+/// discarded---actually, it's kept around in case something on the cut
+/// stack needs it---and a new one is created from scratch.
+///
+/// In the main LyX code, DocumentClass objects are created only by
+/// DocumentClassBundle, for which see below.
+///
+class DocumentClass : public TextClass, boost::noncopyable {
+public:
+ ///
+ virtual ~DocumentClass() {}
+
+ ///////////////////////////////////////////////////////////////////
+ // Layout Info
+ ///////////////////////////////////////////////////////////////////
+ /// \return true if there is a Layout with latexname lay
+ bool hasLaTeXLayout(std::string const & lay) const;
+ /// A DocumentClass nevers count as loaded, since it is dynamic
+ virtual bool loaded() { return false; }
+ /// \return the layout object of an inset given by name. If the name
+ /// is not found as such, the part after the ':' is stripped off, and
+ /// searched again. In this way, an error fallback can be provided:
+ /// An erroneous 'CharStyle:badname' (e.g., after a documentclass switch)
+ /// will invoke the layout object defined by name = 'CharStyle'.
+ /// If that doesn't work either, an empty object returns (shouldn't
+ /// happen). -- Idea JMarc, comment MV
+ InsetLayout const & insetLayout(docstring const & name) const;
+ /// a plain inset layout for use as a default
+ static InsetLayout const & plainInsetLayout() { return plain_insetlayout_; }
+ /// add a new layout \c name if it does not exist in layoutlist_
+ void addLayoutIfNeeded(docstring const & name) const;
+
+ ///////////////////////////////////////////////////////////////////
+ // accessors
+ ///////////////////////////////////////////////////////////////////
+ /// the list of floats defined in the document class
+ FloatList const & floats() const { return floatlist_; }
+ ///
+ Counters & counters() const { return counters_; }
+ ///
+ std::string const & opt_fontsize() const { return opt_fontsize_; }
+ ///
+ std::string const & opt_pagestyle() const { return opt_pagestyle_; }
+ ///
+ std::string const & options() const { return options_; }
+ ///
+ std::string const & class_header() const { return class_header_; }
+ ///
+ std::string const & pagestyle() const { return pagestyle_; }
+ ///
+ docstring const & preamble() const { return preamble_; }
+ ///
+ docstring const & htmlpreamble() const { return htmlpreamble_; }
+ /// is this feature already provided by the class?
+ bool provides(std::string const & p) const;
+ /// features required by the class?
+ std::set<std::string> const & requires() const { return requires_; }
+ ///
+ unsigned int columns() const { return columns_; }
+ ///
+ PageSides sides() const { return sides_; }
+ ///
+ int secnumdepth() const { return secnumdepth_; }
+ ///
+ int tocdepth() const { return tocdepth_; }
+ ///
+ FontInfo const & defaultfont() const { return defaultfont_; }
+ /// Text that dictates how wide the left margin is on the screen
+ docstring const & leftmargin() const { return leftmargin_; }
+ /// Text that dictates how wide the right margin is on the screen
+ docstring const & rightmargin() const { return rightmargin_; }
+ /// The type of command used to produce a title
+ TitleLatexType titletype() const { return titletype_; }
+ /// The name of the title command
+ std::string const & titlename() const { return titlename_; }
+ ///
+ int size() const { return layoutlist_.size(); }
+ /// The minimal TocLevel of sectioning layouts
+ int min_toclevel() const { return min_toclevel_; }
+ /// The maximal TocLevel of sectioning layouts
+ int max_toclevel() const { return max_toclevel_; }
+ /// returns true if the class has a ToC structure
+ bool hasTocLevels() const;
+protected:
+ /// Constructs a DocumentClass based upon a LayoutFile.
+ DocumentClass(LayoutFile const & tc);
+ /// Needed in tex2lyx
+ DocumentClass() {}
+private:
+ /// The only class that can create a DocumentClass is
+ /// DocumentClassBundle, which calls the protected constructor.
+ friend class DocumentClassBundle;
+ ///
+ 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,
+ 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<DocumentClass *> documentClasses_;