]> git.lyx.org Git - lyx.git/blobdiff - src/TextClass.h
Cleanup mouse/selection/context-menu interactions.
[lyx.git] / src / TextClass.h
index 281d2e4c1f4fd8b629c3ea1aa9228a44e7c8a016..71a2241a40ea0e083c24abf5fd486715a4c3ef27 100644 (file)
@@ -11,6 +11,8 @@
 #define TEXTCLASS_H
 
 #include "ColorCode.h"
+#include "Counters.h"
+#include "FloatList.h"
 #include "FontInfo.h"
 #include "Layout.h"
 #include "LayoutEnums.h"
@@ -21,7 +23,6 @@
 #include "support/types.h"
 
 #include <boost/noncopyable.hpp>
-#include <boost/shared_ptr.hpp>
 
 #include <list>
 #include <map>
@@ -68,6 +69,17 @@ public:
        // typedefs
        ///////////////////////////////////////////////////////////////////
        /// The individual paragraph layouts comprising the document class
+       // NOTE Do NOT try to make this a container of Layout pointers, e.g.,
+       // std::vector<Layout *>. This will lead to problems. The reason is
+       // that DocumentClass objects are generally created by copying a 
+       // LayoutFile, which serves as a base for the DocumentClass. If the
+       // LayoutList is a container of pointers, then every DocumentClass
+       // that derives from a given LayoutFile (e.g., article) will SHARE
+       // a basic set of layouts. So if one Buffer were to modify a layout
+       // (say, Standard), that would modify that layout for EVERY Buffer
+       // that was based upon the same DocumentClass. (Of course, if you 
+       // really, REALLY want to make LayoutList a vector<Layout *>, then
+       // you can implement custom assignment and copy constructors.)
        typedef std::vector<Layout> LayoutList;
        /// The inset layouts available to this class
        typedef std::map<docstring, InsetLayout> InsetLayouts;
@@ -115,11 +127,25 @@ public:
        enum ReadType { 
                BASECLASS, //>This is a base class, i.e., top-level layout file
                MERGE, //>This is a file included in a layout file
-               MODULE //>This is a layout module
+               MODULE, //>This is a layout module
+               VALIDATION //>We're just validating
        };
+       /// return values for read()
+       enum ReturnValues {
+               OK,
+               ERROR,
+               FORMAT_MISMATCH
+       };
+
        /// Performs the read of the layout file.
        /// \return true on success.
        bool read(support::FileName const & filename, ReadType rt = BASECLASS);
+       ///
+       bool read(std::string const & str, ReadType rt = BASECLASS);
+       ///
+       ReturnValues read(Lexer & lex, ReadType rt = BASECLASS);
+       /// validates the layout information passed in str
+       static bool validate(std::string const & str);
 
        ///////////////////////////////////////////////////////////////////
        // loading
@@ -167,9 +193,9 @@ protected:
        /// document class description
        std::string description_;
        /// available types of float, eg. figure, algorithm.
-       boost::shared_ptr<FloatList> floatlist_;
+       mutable FloatList floatlist_;
        /// Types of counters, eg. sections, eqns, figures, avail. in document class.
-       boost::shared_ptr<Counters> counters_;
+       mutable Counters counters_;
        /// Has this layout file been loaded yet?
        mutable bool loaded_;
        /// Is the TeX class available?
@@ -219,7 +245,7 @@ protected:
        /// The name of the title command
        std::string titlename_;
        /// Input layouts available to this layout
-       mutable InsetLayouts insetlayoutlist_;
+       InsetLayouts insetlayoutlist_;
        /// The minimal TocLevel of sectioning layouts
        int min_toclevel_;
        /// The maximal TocLevel of sectioning layouts
@@ -230,6 +256,8 @@ private:
        ///////////////////////////////////////////////////////////////////
        ///
        bool deleteLayout(docstring const &);
+       ///
+       bool convertLayoutFormat(support::FileName const &, ReadType);
        /// \return true for success.
        bool readStyle(Lexer &, Layout &);
        ///
@@ -269,7 +297,7 @@ public:
        /// A DocumentClass nevers count as loaded, since it is dynamic
        virtual bool loaded() { return false; }
        /// Inset layouts of this doc class
-       InsetLayouts & insetLayouts() const { return insetlayoutlist_; };
+       InsetLayouts const & insetLayouts() const { return insetlayoutlist_; };
        /// \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:
@@ -277,7 +305,6 @@ public:
        /// 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;
        /// an empty inset layout for use as a default
        static InsetLayout const & emptyInsetLayout() { return empty_insetlayout_; }
@@ -286,11 +313,9 @@ public:
        // accessors
        ///////////////////////////////////////////////////////////////////
        /// the list of floats defined in the document class
-       FloatList & floats() { return *floatlist_.get(); }
-       /// the list of floats defined in the document class
-       FloatList const & floats() const { return *floatlist_.get(); }
-       /// The Counters present in this document class.
-       Counters & counters() const { return *counters_.get(); }
+       FloatList const & floats() const { return floatlist_; }
+       ///
+       Counters & counters() const { return counters_; }
        ///
        std::string const & opt_fontsize() const { return opt_fontsize_; }
        ///