*/
VSpace defskip;
PDFOptions pdfoptions;
+ BaseClassIndex baseClass_;
};
BufferParams::Impl::Impl()
- : defskip(VSpace::MEDSKIP)
+ : defskip(VSpace::MEDSKIP), baseClass_(0)
{
// set initial author
// FIXME UNICODE
string const classname = lex.getString();
// if there exists a local layout file, ignore the system one
// NOTE: in this case, the textclass (.cls file) is assumed to be available.
- pair<bool, lyx::textclass_type> pp =
- make_pair(false, textclass_type(0));
+ pair<bool, lyx::BaseClassIndex> pp =
+ make_pair(false, BaseClassIndex(0));
if (!filepath.empty())
pp = textclasslist.addTextClass(
classname, filepath.absFilename());
// Prints out the buffer info into the .lyx file given by file
// the textclass
- os << "\\textclass " << textclasslist[baseClass_].name() << '\n';
+ os << "\\textclass " << textclasslist[pimpl_->baseClass_].name() << '\n';
// then the preamble
if (!preamble.empty()) {
void BufferParams::useClassDefaults()
{
- TextClass const & tclass = textclasslist[baseClass_];
+ TextClass const & tclass = textclasslist[pimpl_->baseClass_];
sides = tclass.sides();
columns = tclass.columns();
bool BufferParams::hasClassDefaults() const
{
- TextClass const & tclass = textclasslist[baseClass_];
+ TextClass const & tclass = textclasslist[pimpl_->baseClass_];
return sides == tclass.sides()
&& columns == tclass.columns()
}
-bool BufferParams::setBaseClass(textclass_type tc)
+bool BufferParams::setBaseClass(BaseClassIndex tc)
{
if (textclasslist[tc].load()) {
- baseClass_ = tc;
+ pimpl_->baseClass_ = tc;
return true;
}
}
-textclass_type BufferParams::baseClass() const
+BaseClassIndex BufferParams::baseClass() const
{
- return baseClass_;
+ return pimpl_->baseClass_;
}
#include "insets/InsetQuotes.h"
#include "support/copied_ptr.h"
-#include "support/types.h"
#include <vector>
class PDFOptions;
class Spacing;
class TextClass;
+class BaseClassIndex;
class TexRow;
class VSpace;
///
std::string fontsize;
///Get the LyX TextClass (that is, the layout file) this document is using.
- textclass_type baseClass() const;
+ BaseClassIndex baseClass() const;
/// Set the LyX TextClass (that is, the layout file) this document is using.
/// NOTE: This does not call makeTextClass() to update the local TextClass.
/// That needs to be done manually.
- bool setBaseClass(textclass_type);
+ bool setBaseClass(BaseClassIndex);
/// Adds the module information to the baseClass information to
/// create our local TextClass.
void makeTextClass();
/// for use with natbib
biblio::CiteEngine cite_engine_;
- /// the base TextClass associated with the document
- textclass_type baseClass_;
/// the possibly modular TextClass actually in use
TextClassPtr textClass_;
///
#include "TextClassPtr.h"
-#include "support/types.h"
#include "support/docstring.h"
#include "frontends/Clipboard.h"
void loadTextClass(string const & name, string const & buf_path)
{
- pair<bool, textclass_type> const tc_pair =
+ pair<bool, BaseClassIndex> const tc_pair =
textclasslist.numberOfClass(name);
if (!tc_pair.first) {
return;
}
- textclass_type const tc = tc_pair.second;
+ BaseClassIndex const tc = tc_pair.second;
if (!textclasslist[tc].load(buf_path)) {
docstring s = bformat(_("The document class %1$s."
loadTextClass(argument, buffer->filePath());
- pair<bool, textclass_type> const tc_pair =
+ pair<bool, BaseClassIndex> const tc_pair =
textclasslist.numberOfClass(argument);
if (!tc_pair.first)
break;
- textclass_type const old_class = buffer->params().baseClass();
- textclass_type const new_class = tc_pair.second;
+ BaseClassIndex const old_class = buffer->params().baseClass();
+ BaseClassIndex const new_class = tc_pair.second;
if (old_class == new_class)
// nothing to do
BOOST_ASSERT(lyx_view_);
Buffer * buffer = lyx_view_->buffer();
TextClassPtr oldClass = buffer->params().textClassPtr();
- textclass_type const tc = buffer->params().baseClass();
+ BaseClassIndex const tc = buffer->params().baseClass();
textclasslist.reset(tc);
buffer->params().setBaseClass(tc);
buffer->params().makeTextClass();
/// List of inset layouts
typedef std::map<docstring, InsetLayout> InsetLayouts;
+/// Index into global list of base classes (i.e., *.layout).
+/// Basically a 'strong typedef'.
+class BaseClassIndex {
+public:
+ ///
+ typedef size_t base_type;
+ ///
+ BaseClassIndex(base_type t) { data_ = t; }
+ ///
+ operator base_type() const { return data_; }
+ ///
+private:
+ base_type data_;
+};
+
/// Stores the layout specification of a LyX document class.
class TextClass {
public:
using boost::smatch;
// Gets textclass number from name
-pair<bool, textclass_type> const
+pair<bool, BaseClassIndex> const
TextClassList::numberOfClass(string const & textclass) const
{
ClassList::const_iterator cit =
textclass));
return cit != classlist_.end() ?
- make_pair(true, textclass_type(cit - classlist_.begin())) :
- make_pair(false, textclass_type(0));
+ make_pair(true, BaseClassIndex(cit - classlist_.begin())) :
+ make_pair(false, BaseClassIndex(0));
}
// Gets a textclass structure from number
TextClass const &
-TextClassList::operator[](textclass_type textclass) const
+TextClassList::operator[](BaseClassIndex textclass) const
{
if (textclass >= classlist_.size())
return classlist_[0];
}
-void TextClassList::reset(textclass_type const textclass) {
+void TextClassList::reset(BaseClassIndex const textclass) {
if (textclass >= classlist_.size())
return;
TextClass const & tc = classlist_[textclass];
}
-pair<bool, textclass_type> const
+pair<bool, BaseClassIndex> const
TextClassList::addTextClass(string const & textclass, string const & path)
{
// only check for textclass.layout file, .cls can be anywhere in $TEXINPUTS
tmpl.load(path);
// Do not add this local TextClass to classlist_ if it has
// already been loaded by, for example, a master buffer.
- pair<bool, lyx::textclass_type> pp =
+ pair<bool, lyx::BaseClassIndex> pp =
textclasslist.numberOfClass(textclass);
// only layouts from the same directory are considered to be identical.
if (pp.first && classlist_[pp.second].description() == tmpl.description())
}
}
// If .layout is not in local directory, or an invalid layout is found, return false
- return make_pair(false, textclass_type(0));
+ return make_pair(false, BaseClassIndex(0));
}
TextClassList textclasslist;
-textclass_type defaultTextclass()
+BaseClassIndex defaultTextclass()
{
// We want to return the article class. if `first' is
// true in the returned pair, then `second' is the textclass
#include "TextClass.h"
#include "support/strfwd.h"
-#include "support/types.h"
#include <vector>
bool empty() const { return classlist_.empty(); }
/// Gets textclass number from name, -1 if textclass name does not exist
- std::pair<bool, textclass_type> const
- numberOfClass(std::string const & textclass) const;
+ std::pair<bool, BaseClassIndex> const
+ numberOfClass(std::string const & textclass) const;
///
- TextClass const & operator[](textclass_type textclass) const;
+ TextClass const & operator[](BaseClassIndex textclass) const;
/// Read textclass list. Returns false if this fails.
bool read();
/// Clears the textclass so as to force it to be reloaded
- void reset(textclass_type const textclass);
+ void reset(BaseClassIndex const textclass);
/// add a textclass from user local directory.
/// Return ture/false, and textclass number
- std::pair<bool, textclass_type> const
- addTextClass(std::string const & textclass, std::string const & path);
+ std::pair<bool, BaseClassIndex> const
+ addTextClass(std::string const & textclass, std::string const & path);
private:
/// noncopyable
TextClassList(TextClassList const &);
+ /// nonassignable
void operator=(TextClassList const &);
///
///
extern TextClassList textclasslist;
///
-textclass_type defaultTextclass();
+BaseClassIndex defaultTextclass();
} // namespace lyx
void GuiDocument::classChanged()
{
- textclass_type const tc = latexModule->classCO->currentIndex();
+ BaseClassIndex const tc = latexModule->classCO->currentIndex();
bp_.setBaseClass(tc);
if (lyxrc.auto_reset_options) {
if (applyPB->isEnabled()) {
#include "GuiIdListModel.h"
#include "GuiSelectionManager.h"
-#include "support/types.h"
-
#include "ui_DocumentUi.h"
#include "ui_EmbeddedFilesUi.h"
#include "ui_FontUi.h"
break;
case TEXTCLASS_INFO: {
// name_ is the class name
- pair<bool, lyx::textclass_type> pp = textclasslist.numberOfClass(name_);
+ pair<bool, lyx::BaseClassIndex> pp = textclasslist.numberOfClass(name_);
setText(pp.first ? _("yes") : _("no"),
bp.getFont(), false);
break;
#include "ColorCode.h"
#include "Text.h"
-#include "support/types.h"
-
#include <set>
namespace lyx {
#include "support/convert.h"
#include "support/debug.h"
#include "support/lstrings.h"
-#include "support/types.h"
#include <boost/next_prior.hpp>
/// a type for sizes
typedef size_t size_type;
- /// a type used for numbering text classes
- typedef size_t textclass_type;
-
#else
// These structs wrap simple things to make them distinguishible
base_type data_;
};
- struct textclass_type {
- ///
- typedef size_t base_type;
- ///
- textclass_type(base_type t) { data_ = t; }
- ///
- operator base_type() const { return data_; }
- ///
- private:
- base_type data_;
- };
-
-
#endif
///