2001-12-28 13:26:54 +00:00
|
|
|
|
// -*- C++ -*-
|
2003-08-23 00:17:00 +00:00
|
|
|
|
/**
|
2008-03-07 03:53:21 +00:00
|
|
|
|
* \file LayoutFile.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
|
|
|
|
|
2008-03-06 23:31:40 +00:00
|
|
|
|
#include <boost/noncopyable.hpp>
|
|
|
|
|
|
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-03-07 03:53:21 +00:00
|
|
|
|
/// Index into LayoutFileList. 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_; }
|
|
|
|
|
///
|
2008-03-06 21:31:27 +00:00
|
|
|
|
bool empty() const { return data_.empty(); }
|
2008-02-24 16:59:49 +00:00
|
|
|
|
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.
|
2008-03-06 23:31:40 +00:00
|
|
|
|
class LayoutFile : public TextClass, boost::noncopyable {
|
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
|
|
|
|
public:
|
|
|
|
|
/// check whether the TeX class is available
|
|
|
|
|
bool isTeXClassAvailable() const { return texClassAvail_; }
|
|
|
|
|
private:
|
|
|
|
|
/// Construct a layout with default values. Actual values loaded later.
|
2008-03-06 23:31:40 +00:00
|
|
|
|
explicit LayoutFile(std::string const & filename,
|
|
|
|
|
std::string const & className = std::string(),
|
|
|
|
|
std::string const & description = std::string(),
|
|
|
|
|
bool texClassAvail = false);
|
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
|
|
|
|
/// The only class that should create a LayoutFile is
|
2008-03-07 03:53:21 +00:00
|
|
|
|
/// LayoutFileList, which calls the private constructor.
|
|
|
|
|
friend class LayoutFileList;
|
2008-03-06 23:31:40 +00:00
|
|
|
|
/// can't create empty LayoutFile
|
|
|
|
|
LayoutFile() {};
|
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
|
|
|
|
};
|
|
|
|
|
|
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
|
2008-03-07 03:53:21 +00:00
|
|
|
|
/// via LayoutFileList::get()
|
|
|
|
|
class LayoutFileList {
|
2001-12-28 13:26:54 +00:00
|
|
|
|
public:
|
2007-11-07 21:59:19 +00:00
|
|
|
|
///
|
2008-03-07 03:53:21 +00:00
|
|
|
|
LayoutFileList() {}
|
2008-04-16 19:43:06 +00:00
|
|
|
|
~LayoutFileList();
|
2008-02-28 14:49:01 +00:00
|
|
|
|
/// \return The sole instance of this class.
|
2008-03-07 03:53:21 +00:00
|
|
|
|
static LayoutFileList & 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);
|
2008-02-29 02:49:34 +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);
|
2008-03-11 18:31:38 +00:00
|
|
|
|
|
|
|
|
|
enum Layout_Type {
|
|
|
|
|
System,
|
2008-04-20 03:08:11 +00:00
|
|
|
|
Local
|
2008-03-11 18:31:38 +00:00
|
|
|
|
};
|
|
|
|
|
|
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
|
2008-03-11 18:31:38 +00:00
|
|
|
|
addLayoutFile(std::string const & textclass, std::string const & path,
|
|
|
|
|
Layout_Type type);
|
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
|
|
|
|
///
|
2008-03-06 23:31:40 +00:00
|
|
|
|
typedef std::map<std::string, LayoutFile *> ClassMap;
|
2007-11-07 21:52:11 +00:00
|
|
|
|
/// noncopyable
|
2008-03-07 03:53:21 +00:00
|
|
|
|
LayoutFileList(LayoutFileList const &);
|
2008-02-24 16:29:40 +00:00
|
|
|
|
/// nonassignable
|
2008-03-07 03:53:21 +00:00
|
|
|
|
void operator=(LayoutFileList 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
|