]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetoptarg.C
changelogs
[lyx.git] / src / insets / insetoptarg.C
index ed829859cbcf81be43f929929cbed14e3a946893..6b889fd726c74141f2e78636ec03fbf3a8b6471c 100644 (file)
 #include "LColor.h"
 #include "paragraph.h"
 
+#include <sstream>
 
 using std::string;
 using std::auto_ptr;
 using std::ostream;
+using std::ostringstream;
 
 
 InsetOptArg::InsetOptArg(BufferParams const & ins)
@@ -43,7 +45,7 @@ InsetOptArg::InsetOptArg(InsetOptArg const & in)
 }
 
 
-auto_ptr<InsetBase> InsetOptArg::clone() const
+auto_ptr<InsetBase> InsetOptArg::doClone() const
 {
        return auto_ptr<InsetBase>(new InsetOptArg(*this));
 }
@@ -72,8 +74,11 @@ int InsetOptArg::latex(Buffer const &, ostream &,
 int InsetOptArg::latexOptional(Buffer const & buf, ostream & os,
                               OutputParams const & runparams) const
 {
-       os << '[';
-       int const i = InsetText::latex(buf, os, runparams);
-       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;
 }