diff --git a/src/TextClass.cpp b/src/TextClass.cpp index a5ab3e1e0e..24f6bf4b21 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -37,6 +37,8 @@ #include +#include "boost/assert.hpp" + using namespace std; using namespace lyx::support; @@ -114,8 +116,6 @@ InsetLayout DocumentClass::empty_insetlayout_; TextClass::TextClass() { - floatlist_ = boost::shared_ptr(new FloatList); - counters_ = boost::shared_ptr(new Counters); outputType_ = LATEX; columns_ = 1; sides_ = OneSide; @@ -470,7 +470,7 @@ bool TextClass::read(FileName const & filename, ReadType rt) case TC_NOFLOAT: if (lexrc.next()) { string const nofloat = lexrc.getString(); - floatlist_->erase(nofloat); + floatlist_.erase(nofloat); } break; } @@ -712,8 +712,8 @@ void TextClass::readFloat(Lexer & lexrc) case FT_TYPE: lexrc.next(); type = lexrc.getString(); - if (floatlist_->typeExist(type)) { - Floating const & fl = floatlist_->getType(type); + if (floatlist_.typeExist(type)) { + Floating const & fl = floatlist_.getType(type); placement = fl.placement(); ext = fl.ext(); within = fl.within(); @@ -763,13 +763,13 @@ void TextClass::readFloat(Lexer & lexrc) if (getout) { Floating fl(type, placement, ext, within, style, name, listName, builtin); - floatlist_->newFloat(fl); + floatlist_.newFloat(fl); // each float has its own counter - counters_->newCounter(from_ascii(type), from_ascii(within), + counters_.newCounter(from_ascii(type), from_ascii(within), docstring(), docstring()); // also define sub-float counters docstring const subtype = "sub-" + from_ascii(type); - counters_->newCounter(subtype, from_ascii(type), + counters_.newCounter(subtype, from_ascii(type), "\\alph{" + subtype + "}", docstring()); } @@ -816,7 +816,7 @@ void TextClass::readCounter(Lexer & lexrc) case CT_NAME: lexrc.next(); name = lexrc.getDocString(); - if (counters_->hasCounter(name)) + if (counters_.hasCounter(name)) LYXERR(Debug::TCLASS, "Reading existing counter " << to_utf8(name)); else LYXERR(Debug::TCLASS, "Reading new counter " << to_utf8(name)); @@ -844,7 +844,7 @@ void TextClass::readCounter(Lexer & lexrc) // Here if have a full counter if getout == true if (getout) - counters_->newCounter(name, within, + counters_.newCounter(name, within, labelstring, labelstring_appendix); lexrc.popTable(); @@ -950,9 +950,11 @@ bool TextClass::load(string const & path) const InsetLayout const & DocumentClass::insetLayout(docstring const & name) const { docstring n = name; + InsetLayouts::const_iterator cen = insetlayoutlist_.end(); while (!n.empty()) { - if (insetlayoutlist_.count(n) > 0) - return insetlayoutlist_[n]; + InsetLayouts::const_iterator cit = insetlayoutlist_.lower_bound(n); + if (cit != cen && cit->first == n) + return cit->second; size_t i = n.find(':'); if (i == string::npos) break; diff --git a/src/TextClass.h b/src/TextClass.h index 281d2e4c1f..51c42b06a2 100644 --- a/src/TextClass.h +++ b/src/TextClass.h @@ -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 -#include #include #include @@ -167,9 +168,9 @@ protected: /// document class description std::string description_; /// available types of float, eg. figure, algorithm. - boost::shared_ptr floatlist_; + mutable FloatList floatlist_; /// Types of counters, eg. sections, eqns, figures, avail. in document class. - boost::shared_ptr counters_; + mutable Counters counters_; /// Has this layout file been loaded yet? mutable bool loaded_; /// Is the TeX class available? @@ -219,7 +220,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 @@ -269,7 +270,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: @@ -286,11 +287,10 @@ 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_; } /// diff --git a/src/tex2lyx/table.cpp b/src/tex2lyx/table.cpp index 79f750d8c7..40c82b94a8 100644 --- a/src/tex2lyx/table.cpp +++ b/src/tex2lyx/table.cpp @@ -19,6 +19,8 @@ #include "support/convert.h" #include "support/lstrings.h" +#include + #include #include #include diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index bee620818e..54fcd0db8a 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -26,6 +26,8 @@ #include "support/filetools.h" #include "support/lstrings.h" +#include + #include #include #include