]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetoptarg.C
* src/LyXAction.C: mark goto-clear-bookmark as working without buffer
[lyx.git] / src / insets / insetoptarg.C
index 25502904f39aec702280a24539ec632c6d28b1df..d5ed89d3c9a3c4e8cbe75258857e58af8fac750a 100644 (file)
-/* This file is part of
- * ======================================================
+/**
+ * \file insetoptarg.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- *           LyX, The Document Processor
+ * \author Martin Vermeer
  *
- *         Copyright 1995 Matthias Ettrich
- *          Copyright 1995-2001 The LyX Team.
- *
- * ====================================================== */
+ * Full author contact details are available in file CREDITS.
+ */
 
 #include <config.h>
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
+#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 <sstream>
 
-using std::ostream;
-using std::vector;
-using std::pair;
 
-/* OptArg. Used to insert a short version of sectioning header etc.
- *  automatically, or other optional LaTeX arguments */
+namespace lyx {
+
+using std::string;
+using std::auto_ptr;
+using std::ostream;
+using std::ostringstream;
 
 
 InsetOptArg::InsetOptArg(BufferParams const & ins)
-       : InsetCollapsable(ins, true)
+       : InsetCollapsable(ins)
 {
-    LyXFont font(LyXFont::ALL_SANE);
+       LyXFont font(LyXFont::ALL_SANE);
        font.setColor(LColor::collapsable);
        setLabelFont(font);
        setLabel(_("opt"));
 }
 
-InsetOptArg::InsetOptArg(InsetOptArg const & in, bool same_id)
-                   : InsetCollapsable(in, same_id)
+
+InsetOptArg::InsetOptArg(InsetOptArg const & in)
+       : InsetCollapsable(in)
 {
-    LyXFont font(LyXFont::ALL_SANE);
+       LyXFont font(LyXFont::ALL_SANE);
        font.setColor(LColor::collapsable);
        setLabelFont(font);
        setLabel(_("opt"));
 }
 
-Inset * InsetOptArg::clone(Buffer const &, bool same_id) const
+
+auto_ptr<InsetBase> InsetOptArg::doClone() const
 {
-                   return new InsetOptArg(*this, same_id);
+       return auto_ptr<InsetBase>(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 &, bool, 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,
-                               bool, bool fp) const
+
+int InsetOptArg::latexOptional(Buffer const & buf, odocstream & os,
+                              OutputParams const & runparams) const
 {
-       os << '[';
-       int const i = inset.latex(buf, os, false, 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