X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetoptarg.C;h=d5ed89d3c9a3c4e8cbe75258857e58af8fac750a;hb=e28331ed63062dea10d0a21b9ec12034b4b17b9a;hp=04310bb17326ef9341b84032ce2199c5b40e9609;hpb=e1940902fe50ec523fe540f6e11f2ee4045cdfac;p=lyx.git diff --git a/src/insets/insetoptarg.C b/src/insets/insetoptarg.C index 04310bb173..d5ed89d3c9 100644 --- a/src/insets/insetoptarg.C +++ b/src/insets/insetoptarg.C @@ -5,30 +5,31 @@ * * \author Martin Vermeer * - * Full author contact details are available in file CREDITS + * Full author contact details are available in file CREDITS. */ #include +#include "insetoptarg.h" #include "debug.h" - -#include "insetoptarg.h" -#include "support/LOstream.h" -#include "frontends/Alert.h" -#include "support/lstrings.h" // frontStrip, strip -#include "lyxtext.h" -#include "buffer.h" #include "gettext.h" -#include "BufferView.h" -#include "support/lstrings.h" +#include "LColor.h" +#include "paragraph.h" + +#include + +namespace lyx { + +using std::string; +using std::auto_ptr; using std::ostream; -using std::vector; -using std::pair; +using std::ostringstream; + InsetOptArg::InsetOptArg(BufferParams const & ins) - : InsetCollapsable(ins, true) + : InsetCollapsable(ins) { LyXFont font(LyXFont::ALL_SANE); font.setColor(LColor::collapsable); @@ -37,8 +38,8 @@ InsetOptArg::InsetOptArg(BufferParams const & ins) } -InsetOptArg::InsetOptArg(InsetOptArg const & in, bool same_id) - : InsetCollapsable(in, same_id) +InsetOptArg::InsetOptArg(InsetOptArg const & in) + : InsetCollapsable(in) { LyXFont font(LyXFont::ALL_SANE); font.setColor(LColor::collapsable); @@ -47,37 +48,56 @@ InsetOptArg::InsetOptArg(InsetOptArg const & in, bool same_id) } -Inset * InsetOptArg::clone(Buffer const &, bool same_id) const +auto_ptr InsetOptArg::doClone() const { - return new InsetOptArg(*this, same_id); + return auto_ptr(new InsetOptArg(*this)); } -string const InsetOptArg::editMessage() const +docstring const InsetOptArg::editMessage() const { return _("Opened Optional Argument Inset"); } -void InsetOptArg::write(Buffer const * buf, ostream & os) const +void InsetOptArg::write(Buffer const & buf, ostream & os) const { os << "OptArg" << "\n"; InsetCollapsable::write(buf, os); } -int InsetOptArg::latex(Buffer const *, ostream &, LatexRunParams const &, - bool) const +int InsetOptArg::latex(Buffer const &, odocstream &, + OutputParams const &) const +{ + return 0; +} + +int InsetOptArg::docbook(Buffer const &, odocstream &, + OutputParams const &) const +{ + return 0; +} + + +int InsetOptArg::plaintext(Buffer const &, odocstream &, + OutputParams const &) const { return 0; } -int InsetOptArg::latexOptional(Buffer const * buf, ostream & os, - LatexRunParams const & runparams, bool fp) const +int InsetOptArg::latexOptional(Buffer const & buf, odocstream & os, + OutputParams const & runparams) const { - os << '['; - int const i = inset.latex(buf, os, runparams, fp); - os << ']'; - return i + 2; + odocstringstream ss; + int ret = InsetText::latex(buf, ss, runparams); + docstring str = ss.str(); + if (str.find(']') != docstring::npos) + str = '{' + str + '}'; + os << '[' << str << ']'; + return ret; } + + +} // namespace lyx