Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

toc Namespace Reference

Nice functions and objects to handle TOCs. More...


Compounds

struct  toc::TocItem

Typedefs

typedef std::vector< TocItemToc
typedef std::map< string,
Toc
TocList

Functions

string const getType (string const &cmdName)
 Given the cmdName of the TOC param, returns the type used by ControlToc::getContents(). More...

TocList const getTocList (Buffer const *buf)
vector< string > const getTypes (Buffer const *buffer)
void asciiTocList (string const &type, Buffer const *buffer, ostream &os)
bool operator== (TocItem const &a, TocItem const &b)
bool operator!= (TocItem const &a, TocItem const &b)


Detailed Description

Nice functions and objects to handle TOCs.

Typedef Documentation

typedef std::vector<TocItem> toc::Toc
 

Definition at line 55 of file toc.h.

Referenced by MenuItem::MenuItem.

typedef std::map<string, Toc> toc::TocList
 

Definition at line 57 of file toc.h.


Function Documentation

void toc::asciiTocList string const &    type,
Buffer const *    buffer,
std::ostream &   
 

Definition at line 132 of file toc.C.

Referenced by InsetTOC::ascii, and InsetFloatList::ascii.

00133 {
00134         TocList const toc_list = getTocList(buffer);
00135         TocList::const_iterator cit = toc_list.find(type);
00136         if (cit != toc_list.end()) {
00137                 Toc::const_iterator ccit = cit->second.begin();
00138                 Toc::const_iterator end = cit->second.end();
00139                 for (; ccit != end; ++ccit)
00140                         os << ccit->asString() << '\n';
00141         }
00142 }

TocList const toc::getTocList Buffer const *    buf
 

Definition at line 70 of file toc.C.

Referenced by expandToc, and ControlToc::getContents.

00071 {
00072         TocList toclist;
00073         if (!buf)
00074                 return toclist;
00075 
00076         LyXTextClass const & textclass = buf->params.getLyXTextClass();
00077 
00078         ParConstIterator pit = buf->par_iterator_begin();
00079         ParConstIterator end = buf->par_iterator_end();
00080         for (; pit != end; ++pit) {
00081 #ifdef WITH_WARNINGS
00082 #warning bogus type (Lgb)
00083 #endif
00084                 char const labeltype = pit->layout()->labeltype;
00085 
00086                 if (labeltype >= LABEL_COUNTER_CHAPTER
00087                     && labeltype <= LABEL_COUNTER_CHAPTER + buf->params.tocdepth) {
00088                                 // insert this into the table of contents
00089                         const int depth = max(0, labeltype - textclass.maxcounter());
00090                         TocItem const item(pit->id(), depth,
00091                                            pit->asString(buf, true));
00092                         toclist["TOC"].push_back(item);
00093                 }
00094 
00095                 // For each paragraph, traverse its insets and look for
00096                 // FLOAT_CODE or WRAP_CODE
00097                 InsetList::const_iterator it = pit->insetlist.begin();
00098                 InsetList::const_iterator end = pit->insetlist.end();
00099                 for (; it != end; ++it) {
00100                         if (it->inset->lyxCode() == Inset::FLOAT_CODE) {
00101                                 InsetFloat * il =
00102                                         static_cast<InsetFloat*>(it->inset);
00103                                 il->addToToc(toclist, buf);
00104                         } else if (it->inset->lyxCode() == Inset::WRAP_CODE) {
00105                                 InsetWrap * il =
00106                                         static_cast<InsetWrap*>(it->inset);
00107                                 il->addToToc(toclist, buf);
00108                         }
00109                 }
00110         }
00111         return toclist;
00112 }

string const toc::getType string const &    cmdName
 

Given the cmdName of the TOC param, returns the type used by ControlToc::getContents().

Definition at line 60 of file toc.C.

Referenced by MathHullInset::doExtern, QToc::updateType, and FormToc::updateType.

00061 {
00062         // special case
00063         if (cmdName == "tableofcontents")
00064                 return "TOC";
00065         else
00066                 return cmdName;
00067 }

std::vector< string > const toc::getTypes Buffer const *    buffer
 

Definition at line 115 of file toc.C.

Referenced by FormToc::build, ControlToc::getTypes, and FormToc::updateType.

00116 {
00117         vector<string> types;
00118 
00119         TocList const tmp = getTocList(buffer);
00120 
00121         TocList::const_iterator cit = tmp.begin();
00122         TocList::const_iterator end = tmp.end();
00123 
00124         for (; cit != end; ++cit) {
00125                 types.push_back(cit->first);
00126         }
00127 
00128         return types;
00129 }

bool operator!= TocItem const &    a,
TocItem const &    b
[inline]
 

Definition at line 81 of file toc.h.

00082 {
00083         return !(a == b);
00084 }

bool operator== TocItem const &    a,
TocItem const &    b
[inline]
 

Definition at line 73 of file toc.h.

00074 {
00075         return a.id_ == b.id_ && a.str == b.str;
00076         // No need to compare depth.
00077 }


Generated on Fri Jul 18 01:19:12 2003 for lyx by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002