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
|
|
|
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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
|
|
|
#include "Dialogs.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
#include "BufferView.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-07-21 15:51:07 +00:00
|
|
|
return toc::getTypes(lv_.view()->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...
|
|
|
|
if (!lv_.view()->available()) {
|
2001-06-11 17:20:17 +00:00
|
|
|
return empty_list;
|
2001-03-30 19:24:28 +00:00
|
|
|
}
|
|
|
|
|
2002-07-21 15:51:07 +00:00
|
|
|
toc::TocList tmp = toc::getTocList(lv_.view()->buffer());
|
|
|
|
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;
|
|
|
|
}
|