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.
|
2003-10-08 11:31:51 +00:00
|
|
|
*
|
|
|
|
* Nice functions and objects to handle TOCs
|
2002-07-21 15:51:07 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TOC_H
|
|
|
|
#define TOC_H
|
|
|
|
|
|
|
|
#include <map>
|
2003-09-07 21:25:37 +00:00
|
|
|
#include <iosfwd>
|
2002-07-21 15:51:07 +00:00
|
|
|
#include <vector>
|
2003-10-06 15:43:21 +00:00
|
|
|
#include <string>
|
2002-07-21 15:51:07 +00:00
|
|
|
|
|
|
|
class Buffer;
|
|
|
|
class LyXView;
|
|
|
|
class Paragraph;
|
2003-09-21 18:57:15 +00:00
|
|
|
class FuncRequest;
|
2002-07-21 15:51:07 +00:00
|
|
|
|
2003-07-27 13:18:55 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace toc {
|
2002-07-21 15:51:07 +00:00
|
|
|
|
|
|
|
///
|
2005-01-19 15:03:31 +00:00
|
|
|
class TocItem {
|
|
|
|
public:
|
2003-10-06 15:43:21 +00:00
|
|
|
TocItem(int par_id, int d, std::string const & s)
|
2003-02-22 20:05:13 +00:00
|
|
|
: id_(par_id), depth(d), str(s) {}
|
2002-07-21 15:51:07 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const asString() const;
|
2002-07-21 15:51:07 +00:00
|
|
|
/// set cursor in LyXView to this TocItem
|
|
|
|
void goTo(LyXView & lv_) const;
|
|
|
|
/// the action corresponding to the goTo above
|
2003-09-21 18:57:15 +00:00
|
|
|
FuncRequest 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;
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string str;
|
2002-07-21 15:51:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
///
|
|
|
|
typedef std::vector<TocItem> Toc;
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
typedef std::map<std::string, Toc> TocList;
|
2002-07-21 15:51:07 +00:00
|
|
|
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
TocList const getTocList(Buffer const &);
|
2002-07-21 15:51:07 +00:00
|
|
|
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::vector<std::string> const getTypes(Buffer const &);
|
2002-07-21 15:51:07 +00:00
|
|
|
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
void asciiTocList(std::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() */
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const getType(std::string const & cmdName);
|
2002-07-21 15:51:07 +00:00
|
|
|
|
|
|
|
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
|