]> git.lyx.org Git - lyx.git/blob - src/insets/insettoc.C
fix compilation pb ; update eu.po
[lyx.git] / src / insets / insettoc.C
1 #include <config.h>
2
3 #ifdef __GNUG__
4 #pragma implementation
5 #endif
6
7 #include "gettext.h"
8 #include "insettoc.h"
9 #include "BufferView.h"
10 #include "LyXView.h"
11 #include "frontends/Dialogs.h"
12 #include "debug.h"
13 #include "buffer.h"
14
15 using std::vector;
16
17 string const InsetTOC::getScreenLabel() const 
18 {
19         string const cmdname(getCmdName());
20         
21         if (cmdname == "tableofcontents")
22                 return _("Table of Contents");
23         else if (cmdname == "listof{algorithm}{List of Algorithms}")
24                 return _("List of Algorithms");
25         else if (cmdname == "listoffigures")
26                 return _("List of Figures");
27         else
28                 return _("List of Tables");
29 }
30
31
32 Inset::Code InsetTOC::LyxCode() const
33 {
34         string const cmdname(getCmdName());
35         if (cmdname == "tableofcontents")
36                 return Inset::TOC_CODE;
37         else if (cmdname == "listof{algorithm}{List of Algorithms}")
38                 return Inset::LOA_CODE;
39         else if (cmdname == "listoffigures")
40                 return Inset::LOF_CODE; 
41         else
42                 return Inset::LOT_CODE;
43 }
44
45
46 void InsetTOC::Edit(BufferView * bv, int, int, unsigned int)
47 {
48         bv->owner()->getDialogs()->showTOC(this);
49 }
50
51
52 int InsetTOC::Ascii(Buffer const * buffer, std::ostream & os, int) const
53 {
54         os << getScreenLabel() << "\n\n";
55
56 #if 0
57         Buffer::TocType type;
58         string cmdname = getCmdName();
59         if (cmdname == "tableofcontents")
60                 type = Buffer::TOC_TOC;
61         else if (cmdname == "listof{algorithm}{List of Algorithms}")
62                 type = Buffer::TOC_LOA;
63         else if (cmdname == "listoffigures")
64                 type = Buffer::TOC_LOF; 
65         else
66                 type = Buffer::TOC_LOT;
67
68         vector<vector<Buffer::TocItem> > const toc_list =
69                 buffer->getTocList();
70         vector<Buffer::TocItem> const & toc = toc_list[type];
71         for (vector<Buffer::TocItem>::const_iterator it = toc.begin();
72              it != toc.end(); ++it)
73                 os << string(4 * it->depth, ' ') << it->str << endl;
74 #else
75 #ifdef WITH_WARNINGS
76 #warning Fix Me! (Lgb)
77 #endif
78         string type;
79         string const cmdname = getCmdName();
80         if (cmdname == "tableofcontents")
81                 type = "TOC";
82         else if (cmdname == "listof{algorithm}{List of Algorithms}")
83                 type = "LOA";
84         else if (cmdname == "listoffigures")
85                 type = "LOF";
86         else 
87                 type = "LOT";
88
89         Buffer::Lists const toc_list = buffer->getLists();
90         Buffer::Lists::const_iterator cit =
91                 toc_list.find(type);
92         if (cit != toc_list.end()) {
93                 Buffer::SingleList::const_iterator ccit = cit->second.begin();
94                 Buffer::SingleList::const_iterator end = cit->second.end();
95                 for (; ccit != end; ++ccit)
96                         os << string(4 * ccit->depth, ' ')
97                            << ccit->str << "\n";
98         }
99 #endif
100         os << "\n";
101         return 0;
102 }
103
104
105 int InsetTOC::Linuxdoc(Buffer const *, std::ostream & os) const
106 {
107         if (getCmdName() == "tableofcontents")
108                 os << "<toc>";
109         return 0;
110 }
111
112
113 int InsetTOC::DocBook(Buffer const *, std::ostream & os) const
114 {
115         if (getCmdName() == "tableofcontents")
116                 os << "<toc></toc>";
117         return 0;
118 }