]> git.lyx.org Git - lyx.git/blob - src/insets/InsetArgument.cpp
Introduce a wrapper class for odocstream to help ensuring that no
[lyx.git] / src / insets / InsetArgument.cpp
1 /**
2  * \file InsetArgument.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 "InsetArgument.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 InsetArgument::InsetArgument(Buffer * buf)
25         : InsetCollapsable(buf)
26 {}
27
28
29 void InsetArgument::write(ostream & os) const
30 {
31         os << "Argument" << "\n";
32         InsetCollapsable::write(os);
33 }
34
35
36 int InsetArgument::latex(otexstream &, OutputParams const &) const
37 {
38         return 0;
39 }
40
41
42 int InsetArgument::plaintext(odocstream &, OutputParams const &) const
43 {
44         return 0; // do not output optional arguments
45 }
46
47
48 int InsetArgument::docbook(odocstream &, OutputParams const &) const
49 {
50         return 0;
51 }
52
53
54 docstring InsetArgument::xhtml(XHTMLStream &, OutputParams const &) const
55 {
56         return docstring();
57 }
58
59 int InsetArgument::latexArgument(otexstream & os,
60                 OutputParams const & runparams, bool optional) const
61 {
62         odocstringstream ss;
63         otexstream ots(ss);
64         int ret = InsetText::latex(ots, runparams);
65         docstring str = ss.str();
66         if (optional && str.find(']') != docstring::npos)
67                 str = '{' + str + '}';
68         os << (optional ? '[' : '{') << str
69            << (optional ? ']' : '}');
70         return ret;
71 }
72
73
74 } // namespace lyx