X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetoptarg.C;h=6b889fd726c74141f2e78636ec03fbf3a8b6471c;hb=10ba1b8918e7da14334bb5573ce2a707671c8b51;hp=04310bb17326ef9341b84032ce2199c5b40e9609;hpb=e1940902fe50ec523fe540f6e11f2ee4045cdfac;p=lyx.git diff --git a/src/insets/insetoptarg.C b/src/insets/insetoptarg.C index 04310bb173..6b889fd726 100644 --- a/src/insets/insetoptarg.C +++ b/src/insets/insetoptarg.C @@ -5,30 +5,28 @@ * * \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 + +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, Collapsed) { LyXFont font(LyXFont::ALL_SANE); font.setColor(LColor::collapsable); @@ -37,8 +35,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,9 +45,9 @@ 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)); } @@ -59,25 +57,28 @@ string const InsetOptArg::editMessage() const } -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 &, ostream &, + 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, ostream & os, + OutputParams const & runparams) const { - os << '['; - int const i = inset.latex(buf, os, runparams, fp); - os << ']'; - return i + 2; + ostringstream ss; + int ret = InsetText::latex(buf, ss, runparams); + string str = ss.str(); + if (str.find(']') != string::npos) + str = '{' + str + '}'; + os << '[' << str << ']'; + return ret; }