]> git.lyx.org Git - lyx.git/blob - src/insets/insetoptarg.C
This is the continuation of my BufferView/LyXView cleanup. This commit replaces Buffe...
[lyx.git] / src / insets / insetoptarg.C
1 /**
2  * \file insetoptarg.C
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 "debug.h"
16 #include "gettext.h"
17 #include "LColor.h"
18 #include "paragraph.h"
19
20 #include <sstream>
21
22 using lyx::docstring;
23
24 using std::string;
25 using std::auto_ptr;
26 using std::ostream;
27 using std::ostringstream;
28
29
30 InsetOptArg::InsetOptArg(BufferParams const & ins)
31         : InsetCollapsable(ins)
32 {
33         LyXFont font(LyXFont::ALL_SANE);
34         font.setColor(LColor::collapsable);
35         setLabelFont(font);
36         // FIXME UNICODE
37         setLabel(lyx::to_utf8(_("opt")));
38 }
39
40
41 InsetOptArg::InsetOptArg(InsetOptArg const & in)
42         : InsetCollapsable(in)
43 {
44         LyXFont font(LyXFont::ALL_SANE);
45         font.setColor(LColor::collapsable);
46         setLabelFont(font);
47         // FIXME UNICODE
48         setLabel(lyx::to_utf8(_("opt")));
49 }
50
51
52 auto_ptr<InsetBase> InsetOptArg::doClone() const
53 {
54         return auto_ptr<InsetBase>(new InsetOptArg(*this));
55 }
56
57
58 docstring const InsetOptArg::editMessage() const
59 {
60         return _("Opened Optional Argument Inset");
61 }
62
63
64 void InsetOptArg::write(Buffer const & buf, ostream & os) const
65 {
66         os << "OptArg" << "\n";
67         InsetCollapsable::write(buf, os);
68 }
69
70
71 int InsetOptArg::latex(Buffer const &, ostream &,
72                        OutputParams const &) const
73 {
74         return 0;
75 }
76
77 int InsetOptArg::docbook(Buffer const &, ostream &,
78                        OutputParams const &) const
79 {
80         return 0;
81 }
82
83
84 int InsetOptArg::plaintext(Buffer const &, ostream &,
85                        OutputParams const &) const
86 {
87         return 0;
88 }
89
90
91 int InsetOptArg::latexOptional(Buffer const & buf, ostream & os,
92                                OutputParams const & runparams) const
93 {
94         ostringstream ss;
95         int ret = InsetText::latex(buf, ss, runparams);
96         string str = ss.str();
97         if (str.find(']') != string::npos)
98                 str = '{' + str + '}';
99         os << '[' << str << ']';
100         return ret;
101 }