]> git.lyx.org Git - features.git/commitdiff
Restore Andre's TextClassIndex, but now in the form of BaseClassIndex. It seems worth...
authorRichard Heck <rgheck@comcast.net>
Sun, 24 Feb 2008 16:29:40 +0000 (16:29 +0000)
committerRichard Heck <rgheck@comcast.net>
Sun, 24 Feb 2008 16:29:40 +0000 (16:29 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23197 a592a061-630c-0410-9148-cb99ea01b6c8

13 files changed:
src/BufferParams.cpp
src/BufferParams.h
src/CutAndPaste.h
src/LyXFunc.cpp
src/TextClass.h
src/TextClassList.cpp
src/TextClassList.h
src/frontends/qt4/GuiDocument.cpp
src/frontends/qt4/GuiDocument.h
src/insets/InsetInfo.cpp
src/insets/InsetText.h
src/output_docbook.cpp
src/support/types.h

index d037fc67ffb2c6e6d18338aebe3d57d03e44e87c..66e829e4372a5360361effef3eded8d0e54a3b9b 100644 (file)
@@ -283,11 +283,12 @@ public:
         */
        VSpace defskip;
        PDFOptions pdfoptions;
+       BaseClassIndex baseClass_;
 };
 
 
 BufferParams::Impl::Impl()
-       : defskip(VSpace::MEDSKIP)
+       : defskip(VSpace::MEDSKIP), baseClass_(0)
 {
        // set initial author
        // FIXME UNICODE
@@ -462,8 +463,8 @@ string const BufferParams::readToken(Lexer & lex, string const & token,
                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());
@@ -677,7 +678,7 @@ void BufferParams::writeFile(ostream & os) const
        // 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()) {
@@ -1343,7 +1344,7 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
 
 void BufferParams::useClassDefaults()
 {
-       TextClass const & tclass = textclasslist[baseClass_];
+       TextClass const & tclass = textclasslist[pimpl_->baseClass_];
 
        sides = tclass.sides();
        columns = tclass.columns();
@@ -1359,7 +1360,7 @@ void BufferParams::useClassDefaults()
 
 bool BufferParams::hasClassDefaults() const
 {
-       TextClass const & tclass = textclasslist[baseClass_];
+       TextClass const & tclass = textclasslist[pimpl_->baseClass_];
 
        return sides == tclass.sides()
                && columns == tclass.columns()
@@ -1386,10 +1387,10 @@ void BufferParams::setTextClass(TextClassPtr tc) {
 }
 
 
-bool BufferParams::setBaseClass(textclass_type tc)
+bool BufferParams::setBaseClass(BaseClassIndex tc)
 {
        if (textclasslist[tc].load()) {
-               baseClass_ = tc;
+               pimpl_->baseClass_ = tc;
                return true;
        }
        
@@ -1401,9 +1402,9 @@ bool BufferParams::setBaseClass(textclass_type tc)
 }
 
 
-textclass_type BufferParams::baseClass() const
+BaseClassIndex BufferParams::baseClass() const
 {
-       return baseClass_;
+       return pimpl_->baseClass_;
 }
 
 
index 2a57dff066a61b60e5816acbee1e10f6db05244a..279dfbe387a0e539786c1ac74e806bb6a5d9be1a 100644 (file)
@@ -23,7 +23,6 @@
 #include "insets/InsetQuotes.h"
 
 #include "support/copied_ptr.h"
-#include "support/types.h"
 
 #include <vector>
 
@@ -43,6 +42,7 @@ class LatexFeatures;
 class PDFOptions;
 class Spacing;
 class TextClass;
+class BaseClassIndex;
 class TexRow;
 class VSpace;
 
@@ -107,11 +107,11 @@ public:
        ///
        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();
@@ -327,8 +327,6 @@ private:
 
        /// 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_;
        ///
index e3ba435b03416560aa8cffe6192800d3aaae8bbb..5cfb5214923c2f60ab99aeff37e4f6b1e0670ece 100644 (file)
@@ -16,7 +16,6 @@
 
 #include "TextClassPtr.h"
 
-#include "support/types.h"
 #include "support/docstring.h"
 
 #include "frontends/Clipboard.h"
index 24a0b3c6cc23b3d43adc7a07aca7b096b1586574..4443be289113071ba97cb018d615131fa0dfef52 100644 (file)
@@ -714,7 +714,7 @@ void showPrintError(string const & name)
 
 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) {
@@ -724,7 +724,7 @@ void loadTextClass(string const & name, string const & buf_path)
                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."
@@ -1607,14 +1607,14 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
 
                        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
@@ -1634,7 +1634,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        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();
index 07b4f16893f49ce1c934c8d9953526f0bad8f080..f7f4d1b11c5c7dd398c0142ed3885f3a283e08f2 100644 (file)
@@ -38,6 +38,21 @@ class FloatList;
 /// 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:
index eb721bfc9c6c8b5470051da8a78f616fb1c59afd..87191b53b045d00f0df6449612c43c5381daf654 100644 (file)
@@ -34,7 +34,7 @@ using boost::regex;
 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 =
@@ -44,14 +44,14 @@ TextClassList::numberOfClass(string const & textclass) const
                             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];
@@ -166,7 +166,7 @@ bool TextClassList::read()
 }
 
 
-void TextClassList::reset(textclass_type const textclass) {
+void TextClassList::reset(BaseClassIndex const textclass) {
        if (textclass >= classlist_.size())
                return;
        TextClass const & tc = classlist_[textclass];
@@ -176,7 +176,7 @@ void TextClassList::reset(textclass_type const 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
@@ -206,7 +206,7 @@ TextClassList::addTextClass(string const & textclass, string const & path)
                                        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())
@@ -221,7 +221,7 @@ TextClassList::addTextClass(string const & textclass, string const & path)
                }
        }
        // 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));
 }
 
 
@@ -229,7 +229,7 @@ TextClassList::addTextClass(string const & textclass, string const & path)
 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
index 8c1b3744d6e93c8500d78997818eaf9c668aecd6..3b0870df40c49ae0004b1d1ac2ce1f33df2fb787 100644 (file)
@@ -15,7 +15,6 @@
 #include "TextClass.h"
 
 #include "support/strfwd.h"
-#include "support/types.h"
 
 #include <vector>
 
@@ -44,26 +43,27 @@ public:
        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 &);
 
        ///
@@ -73,7 +73,7 @@ private:
 ///
 extern TextClassList textclasslist;
 ///
-textclass_type defaultTextclass();
+BaseClassIndex defaultTextclass();
 
 
 } // namespace lyx
index 163d591f3e168bdd42e4bce81f435617243bec50..bc5e201bbb61c3efca4d23cb0b0f92e8155516a2 100644 (file)
@@ -1212,7 +1212,7 @@ void GuiDocument::updatePagestyle(string const & items, string const & sel)
 
 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()) {
index bdcc0260827959dea234433a7b1700ab6abce043..bc5dc1c4b0f76e74dd340b343b42e23a30d85dfb 100644 (file)
@@ -21,8 +21,6 @@
 #include "GuiIdListModel.h"
 #include "GuiSelectionManager.h"
 
-#include "support/types.h"
-
 #include "ui_DocumentUi.h"
 #include "ui_EmbeddedFilesUi.h"
 #include "ui_FontUi.h"
index caca07c6ced5c25a3635374e6c6a2bf961c4f712..5168447a4112d1cd8726d0e1ddc78f5109e1e80c 100644 (file)
@@ -202,7 +202,7 @@ void InsetInfo::updateInfo(Buffer const & buf)
                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;
index 0101724cb1ae336ed1ca6277bc9acdd501a2d9f5..9a75d67d366f756842d0784d2b75a4191f13253d 100644 (file)
@@ -17,8 +17,6 @@
 #include "ColorCode.h"
 #include "Text.h"
 
-#include "support/types.h"
-
 #include <set>
 
 namespace lyx {
index fb52f221d86f0d81dbb3b1aa2fb7961326a24540..c89ca569d02c3105672d50d73af3c69d730e6e47 100644 (file)
@@ -29,7 +29,6 @@
 #include "support/convert.h"
 #include "support/debug.h"
 #include "support/lstrings.h"
-#include "support/types.h"
 
 #include <boost/next_prior.hpp>
 
index 206d2818b15672ca82067794227c4cf2fbde2ed4..94acd680ecfc3a626bbe8e2cf8bea8435695e385 100644 (file)
@@ -39,9 +39,6 @@ namespace lyx {
        /// 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
@@ -60,19 +57,6 @@ namespace lyx {
                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
 
        ///