]> git.lyx.org Git - lyx.git/blob - src/insets/insetfloatlist.C
This commit re-enable the table adjustment with screen whenever the table is bigger...
[lyx.git] / src / insets / insetfloatlist.C
1 /**
2  * \file insetfloatlist.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "insetfloatlist.h"
14
15 #include "buffer.h"
16 #include "bufferparams.h"
17 #include "debug.h"
18 #include "dispatchresult.h"
19 #include "Floating.h"
20 #include "FloatList.h"
21 #include "funcrequest.h"
22 #include "gettext.h"
23 #include "LaTeXFeatures.h"
24 #include "lyxlex.h"
25 #include "metricsinfo.h"
26 #include "toc.h"
27
28 #include "support/lstrings.h"
29
30 using lyx::docstring;
31 using lyx::odocstream;
32 using lyx::support::bformat;
33
34 using std::endl;
35 using std::string;
36 using std::ostream;
37
38
39 InsetFloatList::InsetFloatList()
40         : InsetCommand(InsetCommandParams("floatlist"), "toc")
41 {}
42
43
44 InsetFloatList::InsetFloatList(string const & type)
45         : InsetCommand(InsetCommandParams("floatlist"), "toc")
46 {
47         setCmdName(type);
48 }
49
50
51 docstring const InsetFloatList::getScreenLabel(Buffer const & buf) const
52 {
53         FloatList const & floats = buf.params().getLyXTextClass().floats();
54         FloatList::const_iterator it = floats[getCmdName()];
55         if (it != floats.end())
56                 return buf.B_(it->second.listName());
57         else
58                 return _("ERROR: Nonexistent float type!");
59 }
60
61
62 InsetBase::Code InsetFloatList::lyxCode() const
63 {
64         return InsetBase::FLOAT_LIST_CODE;
65 }
66
67
68 void InsetFloatList::write(Buffer const &, ostream & os) const
69 {
70         os << "FloatList " << getCmdName() << "\n";
71 }
72
73
74 void InsetFloatList::read(Buffer const & buf, LyXLex & lex)
75 {
76         InsetCommand::read(buf, lex);
77         lyxerr[Debug::INSETS] << "FloatList::float_type: " << getCmdName() << endl;
78         if (!buf.params().getLyXTextClass().floats().typeExist(getCmdName()))
79                 lex.printError("InsetFloatList: Unknown float type: `$$Token'");
80 }
81
82
83 int InsetFloatList::latex(Buffer const & buf, odocstream & os,
84                           OutputParams const &) const
85 {
86         FloatList const & floats = buf.params().getLyXTextClass().floats();
87         FloatList::const_iterator cit = floats[getCmdName()];
88
89         if (cit != floats.end()) {
90                 if (cit->second.builtin()) {
91                         // Only two different types allowed here:
92                         string const type = cit->second.type();
93                         if (type == "table") {
94                                 os << "\\listoftables\n";
95                         } else if (type == "figure") {
96                                 os << "\\listoffigures\n";
97                         } else {
98                                 os << "%% unknown builtin float\n";
99                         }
100                 } else {
101                         // FIXME UNICODE
102                         os << "\\listof{" << lyx::from_ascii(getCmdName()) << "}{"
103                            << buf.B_(cit->second.listName()) << "}\n";
104                 }
105         } else {
106                 // FIXME UNICODE
107                 os << "%%\\listof{" << lyx::from_ascii(getCmdName()) << "}{"
108                    << bformat(_("List of %1$s"), lyx::from_utf8(cit->second.name()))
109                    << "}\n";
110         }
111         return 1;
112 }
113
114
115 int InsetFloatList::plaintext(Buffer const & buffer, odocstream & os,
116                               OutputParams const &) const
117 {
118         os << getScreenLabel(buffer) << "\n\n";
119
120         lyx::toc::asciiTocList(getCmdName(), buffer, os);
121
122         os << "\n";
123         return 0;
124 }
125
126
127 void InsetFloatList::validate(LaTeXFeatures & features) const
128 {
129         features.useFloat(getCmdName());
130 }