2001-03-30 19:24:28 +00:00
|
|
|
/* This file is part of
|
2002-03-21 21:21:28 +00:00
|
|
|
* ======================================================
|
2001-03-30 19:24:28 +00:00
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 2001 The LyX Team.
|
|
|
|
*
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* \file ControlToc.C
|
2002-08-15 16:02:22 +00:00
|
|
|
* \author Angus Leeming <leeming@lyx.org>
|
2001-03-30 19:24:28 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
2002-05-29 16:21:03 +00:00
|
|
|
#include "ControlToc.h"
|
2002-07-21 15:51:07 +00:00
|
|
|
#include "toc.h"
|
2001-03-30 19:24:28 +00:00
|
|
|
|
2002-05-29 16:21:03 +00:00
|
|
|
#include "support/lstrings.h" // tostr
|
|
|
|
|
2001-03-30 19:24:28 +00:00
|
|
|
using std::vector;
|
|
|
|
|
2002-07-21 15:51:07 +00:00
|
|
|
class Buffer;
|
2002-06-18 15:44:30 +00:00
|
|
|
|
2001-03-30 19:24:28 +00:00
|
|
|
ControlToc::ControlToc(LyXView & lv, Dialogs & d)
|
|
|
|
: ControlCommand(lv, d, LFUN_TOC_INSERT)
|
2002-06-18 15:44:30 +00:00
|
|
|
{}
|
2001-03-30 19:24:28 +00:00
|
|
|
|
|
|
|
|
2002-07-21 15:51:07 +00:00
|
|
|
void ControlToc::goTo(toc::TocItem const & item) const
|
2001-03-30 19:24:28 +00:00
|
|
|
{
|
2002-07-21 15:51:07 +00:00
|
|
|
item.goTo(lv_);
|
2001-03-30 19:24:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
vector<string> const ControlToc::getTypes() const
|
|
|
|
{
|
2002-08-12 20:17:41 +00:00
|
|
|
return toc::getTypes(buffer());
|
2001-03-30 19:24:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-21 15:51:07 +00:00
|
|
|
toc::Toc const ControlToc::getContents(string const & type) const
|
2001-03-30 19:24:28 +00:00
|
|
|
{
|
2002-07-21 15:51:07 +00:00
|
|
|
toc::Toc empty_list;
|
2001-03-30 19:24:28 +00:00
|
|
|
|
|
|
|
// This shouldn't be possible...
|
2002-08-12 20:17:41 +00:00
|
|
|
if (!bufferIsAvailable()) {
|
2001-06-11 17:20:17 +00:00
|
|
|
return empty_list;
|
2001-03-30 19:24:28 +00:00
|
|
|
}
|
|
|
|
|
2002-08-12 20:17:41 +00:00
|
|
|
toc::TocList tmp = toc::getTocList(buffer());
|
2002-07-21 15:51:07 +00:00
|
|
|
toc::TocList::iterator it = tmp.find(type);
|
2001-03-30 19:24:28 +00:00
|
|
|
if (it == tmp.end()) {
|
2001-06-11 17:20:17 +00:00
|
|
|
return empty_list;
|
2001-03-30 19:24:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return it->second;
|
|
|
|
}
|