2001-12-28 13:26:54 +00:00
|
|
|
|
// -*- C++ -*-
|
2003-08-23 00:17:00 +00:00
|
|
|
|
/**
|
2008-02-24 16:59:49 +00:00
|
|
|
|
* \file BaseClassList.h
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
2008-02-24 16:59:49 +00:00
|
|
|
|
#ifndef BASECLASSLIST_H
|
|
|
|
|
#define BASECLASSLIST_H
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
2007-04-29 19:53:54 +00:00
|
|
|
|
#include "TextClass.h"
|
2004-11-16 20:41:38 +00:00
|
|
|
|
|
2007-11-07 21:52:11 +00:00
|
|
|
|
#include "support/strfwd.h"
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2007-04-29 18:58:28 +00:00
|
|
|
|
class Layout;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
|
|
|
|
/// Reads the style files
|
2006-07-05 17:01:26 +00:00
|
|
|
|
extern bool LyXSetStyle();
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
2008-02-28 21:04:55 +00:00
|
|
|
|
|
2008-02-24 16:59:49 +00:00
|
|
|
|
/// Index into BaseClassList. Basically a 'strong typedef'.
|
This is the last of the commits that hopes to enforce the distinction between "layout files" and "document classes" that was introduced by the modules code. For the most part, these changes just refactor code from TextClass between: (a) a TextClass base class; (b) a LayoutFile subclass, which represents the information in a .layout file; and (c) a DocumentClass subclass, which represents the layout information associated with a Buffer---a LayoutFile plus Modules. Methods from TextClass have been apportioned between the three classes depending upon what is needed where, and signatures have been changed where necessary so that the right kind of class is required.
At this point, there are no simple TextClass objects in the main LyX code, and it is impossible to create them, since the TextClass constructor is protected. Only LayoutFile and DocumentClass objects can be constructed, and for the most part these are constructed only by their respective containers: BaseClassList and DocumentClassBundle. There is an exception: LayoutFile does have a public default constructor, but if anyone knows how to make it go away, please do.
There will be one or two more commits along these lines, but these will be simple renamings. For example, BaseClassList should be LayoutFileList.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23343 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-29 02:45:33 +00:00
|
|
|
|
class LayoutFileIndex {
|
2008-02-24 16:59:49 +00:00
|
|
|
|
public:
|
|
|
|
|
///
|
2008-02-28 21:04:55 +00:00
|
|
|
|
typedef std::string base_type;
|
2008-02-24 16:59:49 +00:00
|
|
|
|
///
|
This is the last of the commits that hopes to enforce the distinction between "layout files" and "document classes" that was introduced by the modules code. For the most part, these changes just refactor code from TextClass between: (a) a TextClass base class; (b) a LayoutFile subclass, which represents the information in a .layout file; and (c) a DocumentClass subclass, which represents the layout information associated with a Buffer---a LayoutFile plus Modules. Methods from TextClass have been apportioned between the three classes depending upon what is needed where, and signatures have been changed where necessary so that the right kind of class is required.
At this point, there are no simple TextClass objects in the main LyX code, and it is impossible to create them, since the TextClass constructor is protected. Only LayoutFile and DocumentClass objects can be constructed, and for the most part these are constructed only by their respective containers: BaseClassList and DocumentClassBundle. There is an exception: LayoutFile does have a public default constructor, but if anyone knows how to make it go away, please do.
There will be one or two more commits along these lines, but these will be simple renamings. For example, BaseClassList should be LayoutFileList.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23343 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-29 02:45:33 +00:00
|
|
|
|
LayoutFileIndex(base_type t) { data_ = t; }
|
2008-02-24 16:59:49 +00:00
|
|
|
|
///
|
|
|
|
|
operator base_type() const { return data_; }
|
|
|
|
|
///
|
|
|
|
|
private:
|
|
|
|
|
base_type data_;
|
|
|
|
|
};
|
|
|
|
|
|
This is the last of the commits that hopes to enforce the distinction between "layout files" and "document classes" that was introduced by the modules code. For the most part, these changes just refactor code from TextClass between: (a) a TextClass base class; (b) a LayoutFile subclass, which represents the information in a .layout file; and (c) a DocumentClass subclass, which represents the layout information associated with a Buffer---a LayoutFile plus Modules. Methods from TextClass have been apportioned between the three classes depending upon what is needed where, and signatures have been changed where necessary so that the right kind of class is required.
At this point, there are no simple TextClass objects in the main LyX code, and it is impossible to create them, since the TextClass constructor is protected. Only LayoutFile and DocumentClass objects can be constructed, and for the most part these are constructed only by their respective containers: BaseClassList and DocumentClassBundle. There is an exception: LayoutFile does have a public default constructor, but if anyone knows how to make it go away, please do.
There will be one or two more commits along these lines, but these will be simple renamings. For example, BaseClassList should be LayoutFileList.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23343 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-29 02:45:33 +00:00
|
|
|
|
/// This class amounts to little more than a `strong typedef'.
|
|
|
|
|
/// A LayoutFile represents the layout information that is
|
|
|
|
|
/// contained in a *.layout file.
|
|
|
|
|
class LayoutFile : public TextClass {
|
|
|
|
|
public:
|
|
|
|
|
/// This should never be used, but it has to be provided for
|
|
|
|
|
/// std::map operator[] to work. Something like:
|
|
|
|
|
/// mapthingy[stuff] = otherthing
|
|
|
|
|
/// creates an empty object before doing the assignment.
|
|
|
|
|
LayoutFile() {}
|
|
|
|
|
/// check whether the TeX class is available
|
|
|
|
|
bool isTeXClassAvailable() const { return texClassAvail_; }
|
|
|
|
|
private:
|
|
|
|
|
/// Construct a layout with default values. Actual values loaded later.
|
|
|
|
|
explicit LayoutFile(std::string const &,
|
|
|
|
|
std::string const & = std::string(),
|
|
|
|
|
std::string const & = std::string(),
|
|
|
|
|
bool texClassAvail = false);
|
|
|
|
|
/// The only class that should create a LayoutFile is
|
|
|
|
|
/// BaseClassList, which calls the private constructor.
|
|
|
|
|
friend class BaseClassList;
|
|
|
|
|
};
|
|
|
|
|
|
2008-02-28 21:04:55 +00:00
|
|
|
|
|
2008-02-24 16:59:49 +00:00
|
|
|
|
/// A list of base document classes (*.layout files).
|
2008-02-28 14:49:01 +00:00
|
|
|
|
/// This is a singleton class. The sole instance is accessed
|
|
|
|
|
/// via BaseClassList::get()
|
2008-02-24 16:59:49 +00:00
|
|
|
|
class BaseClassList {
|
2001-12-28 13:26:54 +00:00
|
|
|
|
public:
|
2007-11-07 21:59:19 +00:00
|
|
|
|
///
|
2008-02-24 16:59:49 +00:00
|
|
|
|
BaseClassList() {}
|
2008-02-28 14:49:01 +00:00
|
|
|
|
/// \return The sole instance of this class.
|
|
|
|
|
static BaseClassList & get();
|
2001-12-28 13:26:54 +00:00
|
|
|
|
///
|
2008-02-28 21:04:55 +00:00
|
|
|
|
bool empty() const { return classmap_.empty(); }
|
2001-12-28 13:26:54 +00:00
|
|
|
|
///
|
2008-02-28 21:04:55 +00:00
|
|
|
|
bool haveClass(std::string const & classname) const;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
///
|
This is the last of the commits that hopes to enforce the distinction between "layout files" and "document classes" that was introduced by the modules code. For the most part, these changes just refactor code from TextClass between: (a) a TextClass base class; (b) a LayoutFile subclass, which represents the information in a .layout file; and (c) a DocumentClass subclass, which represents the layout information associated with a Buffer---a LayoutFile plus Modules. Methods from TextClass have been apportioned between the three classes depending upon what is needed where, and signatures have been changed where necessary so that the right kind of class is required.
At this point, there are no simple TextClass objects in the main LyX code, and it is impossible to create them, since the TextClass constructor is protected. Only LayoutFile and DocumentClass objects can be constructed, and for the most part these are constructed only by their respective containers: BaseClassList and DocumentClassBundle. There is an exception: LayoutFile does have a public default constructor, but if anyone knows how to make it go away, please do.
There will be one or two more commits along these lines, but these will be simple renamings. For example, BaseClassList should be LayoutFileList.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23343 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-29 02:45:33 +00:00
|
|
|
|
LayoutFile const & operator[](std::string const & classname) const;
|
|
|
|
|
///
|
|
|
|
|
LayoutFile & operator[](std::string const & classname);
|
2002-05-29 13:28:11 +00:00
|
|
|
|
/// Read textclass list. Returns false if this fails.
|
2006-04-09 00:26:19 +00:00
|
|
|
|
bool read();
|
2007-09-11 16:42:22 +00:00
|
|
|
|
/// Clears the textclass so as to force it to be reloaded
|
This is the last of the commits that hopes to enforce the distinction between "layout files" and "document classes" that was introduced by the modules code. For the most part, these changes just refactor code from TextClass between: (a) a TextClass base class; (b) a LayoutFile subclass, which represents the information in a .layout file; and (c) a DocumentClass subclass, which represents the layout information associated with a Buffer---a LayoutFile plus Modules. Methods from TextClass have been apportioned between the three classes depending upon what is needed where, and signatures have been changed where necessary so that the right kind of class is required.
At this point, there are no simple TextClass objects in the main LyX code, and it is impossible to create them, since the TextClass constructor is protected. Only LayoutFile and DocumentClass objects can be constructed, and for the most part these are constructed only by their respective containers: BaseClassList and DocumentClassBundle. There is an exception: LayoutFile does have a public default constructor, but if anyone knows how to make it go away, please do.
There will be one or two more commits along these lines, but these will be simple renamings. For example, BaseClassList should be LayoutFileList.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23343 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-29 02:45:33 +00:00
|
|
|
|
void reset(LayoutFileIndex const & tc);
|
2007-05-28 22:27:45 +00:00
|
|
|
|
/// add a textclass from user local directory.
|
2008-02-28 21:04:55 +00:00
|
|
|
|
/// \return the identifier for the loaded file, or else an
|
|
|
|
|
/// empty string if no file was loaded.
|
This is the last of the commits that hopes to enforce the distinction between "layout files" and "document classes" that was introduced by the modules code. For the most part, these changes just refactor code from TextClass between: (a) a TextClass base class; (b) a LayoutFile subclass, which represents the information in a .layout file; and (c) a DocumentClass subclass, which represents the layout information associated with a Buffer---a LayoutFile plus Modules. Methods from TextClass have been apportioned between the three classes depending upon what is needed where, and signatures have been changed where necessary so that the right kind of class is required.
At this point, there are no simple TextClass objects in the main LyX code, and it is impossible to create them, since the TextClass constructor is protected. Only LayoutFile and DocumentClass objects can be constructed, and for the most part these are constructed only by their respective containers: BaseClassList and DocumentClassBundle. There is an exception: LayoutFile does have a public default constructor, but if anyone knows how to make it go away, please do.
There will be one or two more commits along these lines, but these will be simple renamings. For example, BaseClassList should be LayoutFileList.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23343 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-29 02:45:33 +00:00
|
|
|
|
LayoutFileIndex
|
|
|
|
|
addLayoutFile(std::string const & textclass, std::string const & path);
|
2008-02-28 21:04:55 +00:00
|
|
|
|
/// a list of the available classes
|
This is the last of the commits that hopes to enforce the distinction between "layout files" and "document classes" that was introduced by the modules code. For the most part, these changes just refactor code from TextClass between: (a) a TextClass base class; (b) a LayoutFile subclass, which represents the information in a .layout file; and (c) a DocumentClass subclass, which represents the layout information associated with a Buffer---a LayoutFile plus Modules. Methods from TextClass have been apportioned between the three classes depending upon what is needed where, and signatures have been changed where necessary so that the right kind of class is required.
At this point, there are no simple TextClass objects in the main LyX code, and it is impossible to create them, since the TextClass constructor is protected. Only LayoutFile and DocumentClass objects can be constructed, and for the most part these are constructed only by their respective containers: BaseClassList and DocumentClassBundle. There is an exception: LayoutFile does have a public default constructor, but if anyone knows how to make it go away, please do.
There will be one or two more commits along these lines, but these will be simple renamings. For example, BaseClassList should be LayoutFileList.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23343 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-29 02:45:33 +00:00
|
|
|
|
std::vector<LayoutFileIndex> classList() const;
|
2008-02-28 21:04:55 +00:00
|
|
|
|
///
|
|
|
|
|
static std::string const localPrefix;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
private:
|
2008-02-28 21:04:55 +00:00
|
|
|
|
///
|
This is the last of the commits that hopes to enforce the distinction between "layout files" and "document classes" that was introduced by the modules code. For the most part, these changes just refactor code from TextClass between: (a) a TextClass base class; (b) a LayoutFile subclass, which represents the information in a .layout file; and (c) a DocumentClass subclass, which represents the layout information associated with a Buffer---a LayoutFile plus Modules. Methods from TextClass have been apportioned between the three classes depending upon what is needed where, and signatures have been changed where necessary so that the right kind of class is required.
At this point, there are no simple TextClass objects in the main LyX code, and it is impossible to create them, since the TextClass constructor is protected. Only LayoutFile and DocumentClass objects can be constructed, and for the most part these are constructed only by their respective containers: BaseClassList and DocumentClassBundle. There is an exception: LayoutFile does have a public default constructor, but if anyone knows how to make it go away, please do.
There will be one or two more commits along these lines, but these will be simple renamings. For example, BaseClassList should be LayoutFileList.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23343 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-29 02:45:33 +00:00
|
|
|
|
typedef std::map<std::string, LayoutFile> ClassMap;
|
2007-11-07 21:52:11 +00:00
|
|
|
|
/// noncopyable
|
2008-02-24 16:59:49 +00:00
|
|
|
|
BaseClassList(BaseClassList const &);
|
2008-02-24 16:29:40 +00:00
|
|
|
|
/// nonassignable
|
2008-02-24 16:59:49 +00:00
|
|
|
|
void operator=(BaseClassList const &);
|
2001-12-28 13:26:54 +00:00
|
|
|
|
///
|
2008-02-28 21:04:55 +00:00
|
|
|
|
mutable ClassMap classmap_; //FIXME
|
2001-12-28 13:26:54 +00:00
|
|
|
|
};
|
|
|
|
|
|
2007-10-21 10:50:56 +00:00
|
|
|
|
///
|
This is the last of the commits that hopes to enforce the distinction between "layout files" and "document classes" that was introduced by the modules code. For the most part, these changes just refactor code from TextClass between: (a) a TextClass base class; (b) a LayoutFile subclass, which represents the information in a .layout file; and (c) a DocumentClass subclass, which represents the layout information associated with a Buffer---a LayoutFile plus Modules. Methods from TextClass have been apportioned between the three classes depending upon what is needed where, and signatures have been changed where necessary so that the right kind of class is required.
At this point, there are no simple TextClass objects in the main LyX code, and it is impossible to create them, since the TextClass constructor is protected. Only LayoutFile and DocumentClass objects can be constructed, and for the most part these are constructed only by their respective containers: BaseClassList and DocumentClassBundle. There is an exception: LayoutFile does have a public default constructor, but if anyone knows how to make it go away, please do.
There will be one or two more commits along these lines, but these will be simple renamings. For example, BaseClassList should be LayoutFileList.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23343 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-29 02:45:33 +00:00
|
|
|
|
LayoutFileIndex defaultBaseclass();
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
|
#endif
|