]> git.lyx.org Git - lyx.git/blob - src/insets/InsetOptArg.cpp
This should be the last of the commits refactoring the InsetLayout code.
[lyx.git] / src / insets / InsetOptArg.cpp
1 /**
2  * \file InsetOptArg.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Martin Vermeer
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "InsetOptArg.h"
14
15 #include "support/debug.h"
16 #include "support/docstream.h"
17 #include "support/gettext.h"
18
19 using namespace std;
20
21 namespace lyx {
22
23
24 InsetOptArg::InsetOptArg(BufferParams const & ins)
25         : InsetCollapsable(ins)
26 {}
27
28
29 InsetOptArg::InsetOptArg(InsetOptArg const & in)
30         : InsetCollapsable(in)
31 {}
32
33
34 Inset * InsetOptArg::clone() const
35 {
36         return new InsetOptArg(*this);
37 }
38
39
40 docstring const InsetOptArg::editMessage() const
41 {
42         return _("Opened Optional Argument Inset");
43 }
44
45
46 void InsetOptArg::write(Buffer const & buf, ostream & os) const
47 {
48         os << "OptArg" << "\n";
49         InsetCollapsable::write(buf, os);
50 }
51
52
53 int InsetOptArg::latex(Buffer const &, odocstream &,
54                        OutputParams const &) const
55 {
56         return 0;
57 }
58
59
60 int InsetOptArg::plaintext(Buffer const &, odocstream &,
61                            OutputParams const &) const
62 {
63         return 0; // do not output optional arguments
64 }
65
66
67 int InsetOptArg::docbook(Buffer const &, odocstream &,
68                          OutputParams const &) const
69 {
70         return 0;
71 }
72
73
74 int InsetOptArg::latexOptional(Buffer const & buf, odocstream & os,
75                                OutputParams const & runparams) const
76 {
77         odocstringstream ss;
78         int ret = InsetText::latex(buf, ss, runparams);
79         docstring str = ss.str();
80         if (str.find(']') != docstring::npos)
81                 str = '{' + str + '}';
82         os << '[' << str << ']';
83         return ret;
84 }
85
86
87 } // namespace lyx