]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlToc.C
Nothing but a changed email address (trying to factor my tree in in small steps)
[lyx.git] / src / frontends / controllers / ControlToc.C
1 /* This file is part of
2  * ======================================================
3  *
4  *           LyX, The Document Processor
5  *
6  *           Copyright 2001 The LyX Team.
7  *
8  * ======================================================
9  *
10  * \file ControlToc.C
11  * \author Angus Leeming <leeming@lyx.org>
12  */
13
14 #include <config.h>
15
16 #ifdef __GNUG__
17 #pragma implementation
18 #endif
19
20 #include "ControlToc.h"
21 #include "toc.h"
22
23 #include "support/lstrings.h" // tostr
24
25 using std::vector;
26
27 class Buffer;
28
29 ControlToc::ControlToc(LyXView & lv, Dialogs & d)
30         : ControlCommand(lv, d, LFUN_TOC_INSERT)
31 {}
32
33
34 void ControlToc::goTo(toc::TocItem const & item) const
35 {
36         item.goTo(lv_);
37 }
38
39
40 vector<string> const ControlToc::getTypes() const
41 {
42         return toc::getTypes(buffer());
43 }
44
45
46 toc::Toc const ControlToc::getContents(string const & type) const
47 {
48         toc::Toc empty_list;
49
50         // This shouldn't be possible...
51         if (!bufferIsAvailable()) {
52                 return empty_list;
53         }
54
55         toc::TocList tmp = toc::getTocList(buffer());
56         toc::TocList::iterator it = tmp.find(type);
57         if (it == tmp.end()) {
58                 return empty_list;
59         }
60
61         return it->second;
62 }