2002-07-21 15:51:07 +00:00
|
|
|
// -*- C++ -*-
|
2003-08-23 00:17:00 +00:00
|
|
|
/**
|
|
|
|
* \file toc.h
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-07-21 15:51:07 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
* \author Angus Leeming
|
2002-07-21 15:51:07 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-07-21 15:51:07 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TOC_H
|
|
|
|
#define TOC_H
|
|
|
|
|
|
|
|
#include "support/LOstream.h"
|
|
|
|
#include "LString.h"
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
class Buffer;
|
|
|
|
class LyXView;
|
|
|
|
class Paragraph;
|
|
|
|
|
|
|
|
/** Nice functions and objects to handle TOCs
|
|
|
|
*/
|
2003-07-27 13:18:55 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace toc {
|
2002-07-21 15:51:07 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
struct TocItem {
|
2003-02-22 20:05:13 +00:00
|
|
|
TocItem(int par_id, int d, string const & s)
|
|
|
|
: id_(par_id), depth(d), str(s) {}
|
2002-07-21 15:51:07 +00:00
|
|
|
///
|
|
|
|
string const asString() const;
|
|
|
|
/// set cursor in LyXView to this TocItem
|
|
|
|
void goTo(LyXView & lv_) const;
|
|
|
|
/// the action corresponding to the goTo above
|
|
|
|
int action() const;
|
2003-02-22 20:05:13 +00:00
|
|
|
/// Paragraph ID containing this item
|
|
|
|
int id_;
|
|
|
|
/// nesting depth
|
2002-07-21 15:51:07 +00:00
|
|
|
int depth;
|
|
|
|
///
|
|
|
|
string str;
|
|
|
|
};
|
|
|
|
|
|
|
|
///
|
|
|
|
typedef std::vector<TocItem> Toc;
|
|
|
|
///
|
|
|
|
typedef std::map<string, Toc> TocList;
|
|
|
|
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
TocList const getTocList(Buffer const &);
|
2002-07-21 15:51:07 +00:00
|
|
|
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
std::vector<string> const getTypes(Buffer const &);
|
2002-07-21 15:51:07 +00:00
|
|
|
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
void asciiTocList(string const &, Buffer const &, std::ostream &);
|
2002-11-08 01:08:27 +00:00
|
|
|
|
2002-07-21 15:51:07 +00:00
|
|
|
/** Given the cmdName of the TOC param, returns the type used
|
|
|
|
by ControlToc::getContents() */
|
|
|
|
string const getType(string const & cmdName);
|
|
|
|
|
|
|
|
inline
|
|
|
|
bool operator==(TocItem const & a, TocItem const & b)
|
|
|
|
{
|
2003-02-22 20:05:13 +00:00
|
|
|
return a.id_ == b.id_ && a.str == b.str;
|
2002-07-21 15:51:07 +00:00
|
|
|
// No need to compare depth.
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
bool operator!=(TocItem const & a, TocItem const & b)
|
|
|
|
{
|
|
|
|
return !(a == b);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace toc
|
2003-07-27 13:18:55 +00:00
|
|
|
} // namespace lyx
|
2002-07-21 15:51:07 +00:00
|
|
|
|
|
|
|
#endif // CONTROLTOC_H
|