4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Jean-Marc Lasgouttes
8 * \author Angus Leeming
9 * \author Abdelrazak Younes
11 * Full author contact details are available in file CREDITS.
17 #include "DocIterator.h"
19 #include "support/strfwd.h"
37 friend class TocBackend;
40 /// Default constructor for STL containers.
41 TocItem() : dit_(0) {}
43 TocItem(DocIterator const & dit,
47 docstring const & t = docstring()
56 docstring const & str() const;
58 docstring const & tooltip() const;
60 docstring const asString() const;
62 DocIterator const & dit() const;
64 bool isOutput() const { return output_; }
66 /// the action corresponding to the goTo above
67 FuncRequest action() const;
70 /// Current position of item.
76 /// The tooltip string
78 /// Is this item in a note, inactive branch, etc?
84 class Toc : public std::vector<TocItem>
87 typedef std::vector<TocItem>::const_iterator const_iterator;
88 typedef std::vector<TocItem>::iterator iterator;
89 const_iterator item(DocIterator const & dit) const;
90 /// Look for a TocItem given its depth and string.
91 /// \return The first matching item.
92 /// \retval end() if no item was found.
93 iterator item(int depth, docstring const & str);
96 typedef Toc::const_iterator TocIterator;
99 /// A class and no typedef because we want to forward declare it.
100 class TocList : public std::map<std::string, Toc> {};
110 TocBackend(Buffer const * buffer) : buffer_(buffer) {}
112 void setBuffer(Buffer const * buffer) { buffer_ = buffer; }
114 void update(bool output_active);
115 /// \return true if the item was updated.
116 bool updateItem(DocIterator const & pit);
119 TocList const & tocs() const { return tocs_; }
120 TocList & tocs() { return tocs_; }
123 Toc const & toc(std::string const & type) const;
124 Toc & toc(std::string const & type);
126 /// Return the first Toc Item before the cursor
128 std::string const & type, ///< Type of Toc.
129 DocIterator const & dit ///< The cursor location in the document.
133 void writePlaintextTocList(std::string const & type,
134 odocstringstream & os, size_t max_length) const;
140 Buffer const * buffer_;
143 inline bool operator==(TocItem const & a, TocItem const & b)
145 return a.id() == b.id() && a.str() == b.str() && a.depth() == b.depth();
149 inline bool operator!=(TocItem const & a, TocItem const & b)
157 #endif // TOC_BACKEND_H