2002-09-05 14:10:50 +00:00
|
|
|
/**
|
|
|
|
* \file ControlToc.C
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2001-03-30 19:24:28 +00:00
|
|
|
*
|
2002-09-05 14:10:50 +00:00
|
|
|
* \author Angus Leeming
|
2001-03-30 19:24:28 +00:00
|
|
|
*
|
2002-09-05 14:10:50 +00:00
|
|
|
* Full author contact details are available in file CREDITS
|
2001-03-30 19:24:28 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2002-10-21 17:38:09 +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;
|
|
|
|
}
|