]> git.lyx.org Git - lyx.git/blob - src/toc.h
abf7c4b41f1b92d21abc04a1ff1e93d90a37479d
[lyx.git] / src / toc.h
1 // -*- C++ -*-
2 /**
3  * \file toc.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Jean-Marc Lasgouttes
8  * \author Angus Leeming
9  *
10  * Full author contact details are available in file CREDITS.
11  *
12  * Nice functions and objects to handle TOCs
13  */
14
15 #ifndef TOC_H
16 #define TOC_H
17
18 #include <map>
19 #include <iosfwd>
20 #include <vector>
21 #include <string>
22
23 #include "pariterator.h"
24
25 class Buffer;
26 class LyXView;
27 class Paragraph;
28 class FuncRequest;
29 class LCursor;
30
31 namespace lyx {
32 namespace toc {
33
34 ///
35 class TocItem {
36 public:
37         TocItem(int par_id, int d, std::string const & s)
38                 : id_(par_id), depth(d), str(s) {}
39         ///
40         std::string const asString() const;
41         /// set cursor in LyXView to this TocItem
42         void goTo(LyXView & lv_) const;
43         /// the action corresponding to the goTo above
44         FuncRequest action() const;
45         /// Paragraph ID containing this item
46         int id_;
47         /// nesting depth
48         int depth;
49         ///
50         std::string str;
51 };
52
53 ///
54 typedef std::vector<TocItem> Toc;
55 ///
56 typedef std::map<std::string, Toc> TocList;
57
58 ///
59 TocList const getTocList(Buffer const &);
60
61 ///
62 std::vector<std::string> const getTypes(Buffer const &);
63
64 /// Return the first TocItem before the cursor
65 TocItem const getCurrentTocItem(Buffer const &, LCursor const &,
66                                                                 std::string const & type);
67
68 ///
69 void asciiTocList(std::string const &, Buffer const &, std::ostream &);
70
71 /** Given the cmdName of the TOC param, returns the type used
72     by ControlToc::getContents() */
73 std::string const getType(std::string const & cmdName);
74
75 /** Returns the guiname from a given @c type
76     The localization of the names will be done in the frontends */
77 std::string const getGuiName(std::string const & type, Buffer const &);
78
79 inline
80 bool operator==(TocItem const & a, TocItem const & b)
81 {
82         return a.id_ == b.id_ && a.str == b.str;
83         // No need to compare depth.
84 }
85
86
87 inline
88 bool operator!=(TocItem const & a, TocItem const & b)
89 {
90         return !(a == b);
91 }
92
93
94 /// the type of outline operation
95 enum OutlineOp {
96         UP, // Move this header with text down
97         DOWN,   // Move this header with text up
98         IN, // Make this header deeper
99         OUT // Make this header shallower
100 };
101
102
103 void outline(OutlineOp, Buffer *, pit_type &);
104
105
106 } // namespace toc
107 } // namespace lyx
108
109 #endif // CONTROLTOC_H