]> git.lyx.org Git - lyx.git/blob - src/TocBuilder.h
Avoid full metrics computation with Update:FitCursor
[lyx.git] / src / TocBuilder.h
1 // -*- C++ -*-
2 /**
3  * \file TocBuilder.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Guillaume Munch
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef TOC_BUILDER_H
13 #define TOC_BUILDER_H
14
15 #include "Toc.h"
16
17 #include "support/strfwd.h"
18
19 #include <stack>
20
21
22 namespace lyx {
23
24 class DocIterator;
25
26 /// Caption-enabled TOC builders
27 class TocBuilder
28 {
29 public:
30         TocBuilder(std::shared_ptr<Toc> toc);
31         /// Open a level.
32         /// When entering a float or flex or paragraph (with AddToToc)
33         void pushItem(DocIterator const & dit, docstring const & s,
34                       bool output_active, bool is_captioned = false);
35         /// Edit entry at current level. Add new entry if already captioned.
36         /// When encountering a float caption
37         void captionItem(DocIterator const & dit, docstring const & s,
38                          bool output_active);
39         /// Edit entry at current level (always).
40         /// When encountering an argument (with isTocCaption) for flex or paragraph
41         void argumentItem(docstring const & arg_str);
42         /// Close a level.
43         /// When exiting a float or flex or paragraph
44         void pop();
45 private:
46         TocBuilder(){}
47         ///
48         struct frame {
49                 Toc::size_type pos;
50                 bool is_captioned;
51         };
52         ///
53         std::shared_ptr<Toc> const toc_;
54         ///
55         std::stack<frame> stack_;
56 };
57
58
59 } // namespace lyx
60
61 #endif // TOC_BUILDER_H