]> git.lyx.org Git - lyx.git/blob - src/toc.h
Fix bug 2485 and crash on middle mouse paste on math
[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
30 namespace lyx {
31 namespace toc {
32
33 ///
34 class TocItem {
35 public:
36         TocItem(int par_id, int d, std::string const & s)
37                 : id_(par_id), depth(d), str(s) {}
38         ///
39         std::string const asString() const;
40         /// set cursor in LyXView to this TocItem
41         void goTo(LyXView & lv_) const;
42         /// the action corresponding to the goTo above
43         FuncRequest action() const;
44         /// Paragraph ID containing this item
45         int id_;
46         /// nesting depth
47         int depth;
48         ///
49         std::string str;
50 };
51
52 ///
53 typedef std::vector<TocItem> Toc;
54 ///
55 typedef std::map<std::string, Toc> TocList;
56
57 ///
58 TocList const getTocList(Buffer const &);
59
60 ///
61 std::vector<std::string> const getTypes(Buffer const &);
62
63 ///
64 void asciiTocList(std::string const &, Buffer const &, std::ostream &);
65
66 /** Given the cmdName of the TOC param, returns the type used
67     by ControlToc::getContents() */
68 std::string const getType(std::string const & cmdName);
69
70 /** Returns the guiname from a given @c type
71     The localization of the names will be done in the frontends */
72 std::string const getGuiName(std::string const & type, Buffer const &);
73
74 inline
75 bool operator==(TocItem const & a, TocItem const & b)
76 {
77         return a.id_ == b.id_ && a.str == b.str;
78         // No need to compare depth.
79 }
80
81
82 inline
83 bool operator!=(TocItem const & a, TocItem const & b)
84 {
85         return !(a == b);
86 }
87
88
89 /// the type of outline operation
90 enum OutlineOp {
91         UP, // Move this header with text down
92         DOWN,   // Move this header with text up
93         IN, // Make this header deeper
94         OUT // Make this header shallower
95 };
96
97
98 void outline(OutlineOp, Buffer *, pit_type &);
99
100
101 } // namespace toc
102 } // namespace lyx
103
104 #endif // CONTROLTOC_H